AVR timers
Timer1 in fast PWM mode 14, with ICR1 as the top: 1000 Hz at 25 percent on pin 9 with 2000 steps of resolution, beside analogWrite()’s fixed 490 Hz on pin 3, and then 5 kHz from one register.
Open it in the simulatorThe counter, prescaler, top and compare behind every timer, set up by hand on the Uno, the ESP32-C3’s LEDC, the RP2040’s PWM slices and the STM32’s TIM3, every frequency checked by a counter on the pin; input capture as a reciprocal counter; and one PWM driver with the same calls on all four chips.
0 of 7 done
7 lessons in 4 chapters, about 6 hours on a simulated Arduino Uno R3. Free, in your browser, every step checked by the simulator.
Timer1 in fast PWM mode 14, with ICR1 as the top: 1000 Hz at 25 percent on pin 9 with 2000 steps of resolution, beside analogWrite()’s fixed 490 Hz on pin 3, and then 5 kHz from one register.
Open it in the simulatorTIM3 on the STM32F411 Black Pill with two PWM channels on PA6 and PA7 sharing one period: PSC and ARR from an 84 MHz clock, a CCR per channel, and center-aligned counting that halves the frequency.
Open it in the simulatorEach lesson opens when the one before it is done, and each chapter ends in a project.
A counter, a prescaler and a compare register, then PWM on the AVR.
A timer is a counter, a prescaler and a compare register. Timer1 on the Uno toggles pin 9 in hardware once a second and fires an interrupt on every match; one register change makes it sing at 1953 Hz.
0 of 6 steps
Timer1 in fast PWM mode 14, with ICR1 as the top: 1000 Hz at 25 percent on pin 9 with 2000 steps of resolution, beside analogWrite()’s fixed 490 Hz on pin 3, and then 5 kHz from one register.
0 of 5 steps
The ESP32-C3’s LEDC, the RP2040’s slices and the STM32’s TIM3.
The ESP32-C3’s LED PWM controller: a channel on any pin, a frequency and a resolution traded against an 80 MHz clock, a 440 Hz tone on a second pin, and a pair of settings the hardware refuses.
0 of 5 steps
The RP2040’s eight PWM slices by register: a divider, a TOP and two compare values. GP2 and GP3 share slice 1 and so one frequency, each with its own duty, and an 8.4 fixed-point divider doubles the frequency.
0 of 5 steps
TIM3 on the STM32F411 Black Pill with two PWM channels on PA6 and PA7 sharing one period: PSC and ARR from an 84 MHz clock, a CCR per channel, and center-aligned counting that halves the frequency.
0 of 5 steps
Input capture, overflow counting and a reciprocal counter.
Input capture: Timer1 timestamps every rising edge on pin 8 in hardware, an overflow count makes the time 32 bits wide, and timing many periods at once makes a reciprocal counter that reads 1000.0 Hz, then 50.1 Hz.
0 of 5 steps
One PWM driver with the same calls on four chips.
The same three calls (pwmBegin, pwmDuty, pwmTone) and the same application on an Uno, an ESP32-C3, a Pico and a Black Pill at once: a breathing lamp at 1 kHz and a 440 Hz tone, each driver on its own chip’s timers.
0 of 6 steps
All 7 lessons, in order, each with what it covers. Any of them opens in the editor right away.
Every lesson runs in the simulator with nothing to buy. When you want the real thing, these kits have the parts.
Pick the starter kit you own and run every lesson in its manual with the same parts on the same pins.
See every kitYes. All 7 lessons of Timers, PWM and capture on four chips are free and run in your browser, with nothing to install and no parts to buy before you start.
No. Every lesson runs on a simulated Arduino Uno R3 with its parts on the canvas, and the simulator checks each step as you go. When you want to build it for real, the same wiring and code work on a real board.
About 6 hours: 7 lessons in 4 chapters, each one a few short steps. Your progress is kept, so you can stop after any lesson and pick up where you left off.
Each chapter ends in a project that puts it together: AVR timers and STM32 timers.
With "Timer basics", and each lesson builds on the one before it. New to circuits? Electronics basics is the course that starts from zero.