Inside the timer
Counter register
Select a block to see how it contributes to counting and rollover.
Four cascaded T flip-flops form the counter. A period comparator and reset feedback create the timer event.
Clock, count, and interrupt
Counter steps may be compressed when zoomed out. Event arrows mark instants; the cursor marks the inspected source edge.
How to read the timer
Why does PR need “+1”?
A PR of 9 holds ten count states: 0, 1, …, 9. The comparator is high while COUNT = 9. The following timer tick loads 0 and generates the event, completing ten ticks.
What does prescaling change?
A larger prescaler spreads timer ticks farther apart. It extends the longest interval you can represent with the same number of counter bits, but makes the time adjustment coarser. It changes the tick rate; it does not add storage bits.
Interrupt rate or output frequency?
An output that toggles once per interrupt needs two interrupts for one complete square-wave cycle. Its output frequency is half the interrupt-event rate. The green trace shows this ideal toggling behavior.
Automatic fitting. Every available prescaler is checked. The simulator chooses the PR/prescaler pair with the smallest absolute time error; equal solutions prefer the smaller prescaler. A half-tick rounds upward. Requests outside the timer’s range use the nearest endpoint and show a warning. Direct PR and prescaler edits preserve the other register.
Timing convention. COUNT holds each value from 0 through PR, so an interval contains PR + 1 timer ticks. PR = 0 generates an event on every timer tick. A terminal match is the level COUNT = PR; the event occurs on the following timer tick. Event markers indicate instants, not the physical width of an interrupt signal.
Model scope. This is an ideal periodic up-counter. The divided clock is represented by timer-tick markers. Playback speed changes only the animation. CPU interrupt latency, interrupt enable/flag registers, external-clock modes, PWM, clock jitter, ripple propagation, and writes during counting are not modeled. Changes to timer settings reset the simulation to source edge 0.
Prescaler choices. Use every power of two from 1 through 256, or enter a custom set. Custom entries must be positive integer powers of two from 1 through 65,536; values are sorted and duplicates are removed. After a time edit, hardware changes refit the requested interval. After a register edit, hardware changes retain the registers where possible.