Datasheet
98
ATmega169A/PA/329A/PA/649A/P/3290A/PA/6490A/P [DATASHEET]
8284E–AVR–02/2013
15.5 Output Compare Unit
The 8-bit comparator continuously compares TCNT0 with the Output Compare Register (OCR0A). Whenever
TCNT0 equals OCR0A, the comparator signals a match. A match will set the Output Compare Flag (OCF0A) at the
next timer clock cycle. If enabled (OCIE0A = 1 and Global Interrupt Flag in SREG is set), the Output Compare Flag
generates an Output Compare interrupt. The OCF0A Flag is automatically cleared when the interrupt is executed.
Alternatively, the OCF0A Flag can be cleared by software by writing a logical one to its I/O bit location. The Wave-
form Generator uses the match signal to generate an output according to operating mode set by the WGM01:0 bits
and Compare Output mode (COM0A1: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 (See ”Modes of Operation” on
page 100.).
Figure 15-3 shows a block diagram of the Output Compare unit.
Figure 15-3. Output Compare Unit, block diagram.
The OCR0A Register is double buffered when using any of the Pulse Width Modulation (PWM) modes. For the nor-
mal and Clear Timer on Compare (CTC) modes of operation, the double buffering is disabled. The double buffering
synchronizes the update of the OCR0 Compare Register 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 OCR0A Register access may seem complex, but this is not case. When the double buffering is enabled, the
CPU has access to the OCR0A Buffer Register, and if double buffering is disabled the CPU will access the OCR0A
directly.
15.5.1 Force Output Compare
In non-PWM waveform generation modes, the match output of the comparator can be forced by writing a one to
the Force Output Compare (FOC0A) bit. Forcing compare match will not set the OCF0A Flag or reload/clear the
timer, but the OC0A pin will be updated as if a real compare match had occurred (the COM0A1:0 bits settings
define whether the OC0A pin is set, cleared or toggled).
OCFnx (Int.Req.)
= (8-bit Comparator )
OCRnx
OCnx
DATA B U S
TCNTn
WGMn1:0
Waveform Generator
top
FOCn
COMnX1:0
bottom