Datasheet

Table Of Contents
Figure 20-10. Timer/Counter Timing Diagram, Setting of OCF2, with Prescaler (f
clk_I/O
/8)
OCFn
OCRn
TCNTn
OCRn Value
OCRn - 1 OCRn OCRn + 1 OCRn + 2
clk
I/O
clk
Tn
(clk
I/O
/8)
The figure below shows the setting of OCF2 and the clearing of TCNT2 in CTC mode.
Figure 20-11. Timer/Counter Timing Diagram, Clear Timer on Compare Match Mode, with Prescaler (f
clk_I/O
/8)
OCFn
OCRn
TCNTn
(CTC)
TOP
TOP - 1 TOP BOTTOM BOTTOM + 1
clk
I/O
clk
Tn
(clk
I/O
/8)
20.9. Asynchronous Operation of the Timer/Counter
20.9.1. Asynchronous Operation of Timer/Counter2
When Timer/Counter2 operates asynchronously, some considerations must be taken.
Warning: When switching between asynchronous and synchronous clocking of Timer/Counter2, the
Timer Registers TCNT2, OCR2, and TCCR2 might be corrupted. A safe procedure for switching
clock source is:
1. Disable the Timer/Counter2 interrupts by clearing OCIE2 and TOIE2.
2. Select clock source by setting AS2 as appropriate.
3. Write new values to TCNT2, OCR2, and TCCR2.
4. To switch to asynchronous operation: Wait for TCN2UB, OCR2UB, and TCR2UB.
5. Clear the Timer/Counter2 Interrupt Flags.
Atmel ATmega32A [DATASHEET]
Atmel-8155I-ATmega32A_Datasheet_Complete-08/2016
150