Actions

AVR timer interrupts

From Just in Time

Revision as of 23:34, 30 November 2009 by Danny (talk | contribs) (→‎Registers)

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
(output compare register). As soon as the timer reaches a value that is in this register, the appropriate bit in TIFR is set. This bit is set if the timer runs in CTC-mode, which can be switched on by setting WGMx0-WGMx3 to 0100 (setting WGMx2 to 1).