Make every tick count.
Explore AVR timers. Follow a demonstration, then change the registers yourself.
Playback is slowed for observation. Simulated time uses the clock and prescaler, independently of playback speed.
Counter over time
Most recent 700 ticks · event markers in amberLive registers
Control bits follow the applied settings. Flags stay set until cleared. Select a flag to write 1 and clear it.
Timing calculation
Recent events & totals
Try these experiments
- With Timer0 in normal mode, start at 250. Predict how many ticks remain before overflow.
- Choose CTC, set OCRnA to 9 and OCRnB to 4. Which flag appears first? Does compare B reset the counter?
- Double the prescaler. What happens to the tick period and the interval between events?
- Use Timer1, CTC, 16 MHz and /1024. Find OCR1A for a 0.5-second interval.
Check your answer
7,811.5 ticks would be needed, so exactly 0.5 s is impossible with /1024. OCR1A = 7,811 gives 0.499968 s; 7,812 gives 0.500032 s. Use /256 and OCR1A = 31,249 for exactly 0.5 s.
Model scope & timing notes
This is a standalone synchronous timer model, not a full CPU emulator. It covers normal mode and CTC with OCRnA as TOP, compare A/B, prescalers, counter values, and sticky flags. It excludes PWM, interrupts, output pins, external clocks, asynchronous Timer2, prescaler phase, and byte-access timing. Timer1 values are shown as combined 16-bit registers and high/low bytes. Control fields outside this model remain zero.
Each step is a prescaled timer edge. Equality during a count interval sets OCF on the following timer edge; CTC clears at that edge. Thus a cycle from zero takes OCRnA + 1 ticks. Overflow sets TOV on MAX → 0. OCRnB never sets TOP. CTC clearing is a compare event.
Normal-mode preload affects only the first interval unless software writes it again. The optional reload assumes no software latency. Settings are applied together while stopped; live register-write edge cases are outside this model.
Hardware reference: Microchip ATmega328P datasheet, timer chapters.