How to Select a Timer on AVR MCUs
How to Select a Timer on AVR MCUs
Modern AVR has a wide variety of Timers (TCA, TCB most commonly, but TCD, TCE, and TCF are uncommon and specific to particular AVR chips).
This can make choosing a AVR DD vs AVR EA vs AVR EB vs AVR DA a difficult choice, especially if you're trying to use timers to their greatest extent possible.
This blogpost covers a basic idea of what the different timers offer.
The blogpost is short enough. I feel like what I can add is to highlight the difference between:
- Timers -- A background count++, a comparator of count vs some pre-configured values, and then likely an output pin that changes based off of these configurations. Consider this an MCU output. Almost everything listed can be used as a timer.
- Counters -- Counter functionality is an MCU input. Many protocols, such as Servos, PWM, pulse-train decoding requires a variety of pulse-frequency-modulation, pulse-counting, or wide variety of other kinds of common tasks. "TCB" may be called a "Timer", but its really more of a counter-focused device which can more easily measure frequencies (for pulse-frequency-modulation). TCA and a few others can do some basic counting tasks, but usually not as well as TCB.
The other discussions in the blog are easy enough to understand IMO. This is all AVR specific, but some of the best material online are highly specialized articles like this, so I still feel like sharing.
Reminds me of my university days programming for this target which then exploded in popularity with Arduino and the maker movement.
These new AVR DA / DB / DD / EA / EB series over the past couple of years is really excellent IMO.
I feel like "x16 Programmable Gain Differential 12-bit ADC" on the AVR EA should give you a reason to check things out! CCL (Four 3-LUTs + 2 1-bit memory cells) can operate while the processor is in sleep states, allowing for some customizable glue logic.
These timers today are certainly more powerful than what came out 15 years ago too.
Each AVR series has a "secret weapon" that's pretty cool. AVR DB has 3x OpAmps. EA is that x16 PGA Differential 12-bit ADC like I said. EB has these new waveforms.
This post: https://lemmy.world/post/16422711 shows off how to use Timers, CCL and the event system to create a bang-bang Boost converter that operates even under CPU sleep (since its all Timers / Peripherals).
With a more advanced timer like Timer E, that same design can upgrade to a nmos+pmos totem pole Boost Converter somewhat easily as well. (Replace the diode with a pmos + use TimerE to configure dead-time + complementary on/off signals that can operate all during standby-sleep).
I find this especially interesting because a lot of cheap AVR cores are used to implement simple logic, so additional tools to do that efficiently meets pushes what’s possible in an application.