AVR timer interrupts
From Just in Time
Summary "howto" setup timer interrupts on AVR
Registers
- TCNTx
- is the timer counter itself. It's both readable and writeable. The counter starts as soon as prescale value is written to the CSxn (e.g. CS10 and CS11) bits, which are located in TCCRxB.
- OCRxA and OCRxB
- (output compare registers). As soon as the timer reaches a value that is in one of these registers, the appropriate bit in TIFR is set. This bit is only set if the timer runs in CTC-mode, which can be switched on by setting WGMx0-WGMx3 to 0100 (setting WGMx2 to 1).