ABC of Electronics cosycom.com
EMBEDDED SYSTEMS & MICROCONTROLLERS · PAGE 10

Timers and Counters

Hardware that counts clock ticks so firmware does not have to.

A timer is a register that increases on every clock tick, or on every tick divided by a prescaler. When it reaches a chosen compare value it can raise an interrupt, flip a pin or reset itself.

Example: with a 1 MHz timer clock, counting to 1000 takes 1 millisecond. Dividing the clock with a prescaler lets a small 8-bit or 16-bit counter measure long intervals.

A counter works the same way but counts external pulses, which is handy for measuring speed or frequency.