Datasheet

mode (COM0x[1:0]) bits. The max and bottom signals are used by the Waveform Generator for handling
the special cases of the extreme values in some modes of operation.
Figure 16-3. Output Compare Unit, Block Diagram
OCFnx (Int.Req.)
= (8-bit Comparator )
OCRnx
OCnx
DATA BUS
TCNTn
WGMn[1:0]
Waveform Generator
top
FOCn
COMnx[1:0]
bottom
Note:  The “n” in the register and bit names indicates the device number (n = 0 for Timer/Counter 0), and
the “x” indicates Output Compare unit (A/B).
The OCR0x Registers are double buffered when using any of the Pulse Width Modulation (PWM) modes.
When double buffering is enabled, the CPU has access to the OCR0x Buffer Register. The double
buffering synchronizes the update of the OCR0x Compare Registers to either top or bottom of the
counting sequence. The synchronization prevents the occurrence of odd-length, non-symmetrical PWM
pulses, thereby making the output glitch-free.
The double buffering is disabled for the normal and Clear Timer on Compare (CTC) modes of operation,
and the CPU will access the OCR0x directly.
16.5.1. Force Output Compare
In non-PWM waveform generation modes, the match output of the comparator can be forced by writing a
'1' to the Force Output Compare (TCCR0C.FOC0x) bit. Forcing compare match will not set the OCF0x
Flag or reload/clear the timer, but the OC0x pin will be updated as if a real compare match had occurred
(the TCCR0A.COM0x[1:0] bits define whether the OC0x pin is set, cleared or toggled).
16.5.2. Compare Match Blocking by TCNT0 Write
All CPU write operations to the TCNT0 Register will block any compare match that occur in the next timer
clock cycle, even when the timer is stopped. This feature allows OCR0x to be initialized to the same value
as TCNT0 without triggering an interrupt when the Timer/Counter clock is enabled.
16.5.3. Using the Output Compare Unit
Since writing TCNT0 in any mode of operation will block all compare matches for one timer clock cycle,
there are risks involved when changing TCNT0 when using the Output Compare Unit, independently of
whether the Timer/Counter is running or not. If the value written to TCNT0 equals the OCR0x value, the
Atmel ATmega644A [DATASHEET]
Atmel-42716C-ATmega644A_Datasheet_Complete-10/2016
131