Difference between revisions of "AVR timer interrupts"
From Just in Time
m |
m (→Registers) |
||
Line 4: | Line 4: | ||
;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. | ;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|TIFR]] is set. This bit is | + | ;OCRxA: (output compare register). As soon as the timer reaches a value that is in this register, the appropriate bit in [[#TIFR|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). |
Revision as of 23:34, 30 November 2009
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).