
79
ATmega8515(L)
2512A–AVR–04/02
clk
Tn
Timer/Counterclock, referred to asclk
T0
in the following.
top Signalizethat TCNT0 hasreached maximum value.
bottom Signalizethat TCNT0 hasreached minimum value (zero).
Depending of themodeof operation used, the counter iscleared, incremented, ordec-
remented at each timerclock (clk
T0
). clk
T0
can be generatedfrom an external or internal
clock source,selectedbythe Clock Select bits(CS02:0). When no clock sourceis
selected(CS02:0 = 0) thetimer isstopped. However, theTCNT0 value can beaccessed
by the CPU, regardless ofwhetherclk
T0
ispresent or not. A CPUwrite overrides(has
priority over) all counterclear orcount operations.
The counting sequenceisdeterminedbythe setting of the WGM01 andWGM00 bits
located in theTimer/CounterControl Register(TCCR0).Thereare close connections
between how the counterbehaves(counts) andhowwaveforms aregenerated on the
Output Compareoutput OC0. For more details about advancedcounting sequences
andwaveform generation,see “Modes ofOperation” on page 82.
TheTimer/CounterOverflow(TOV0)flag isset accordingtothemodeof operation
selectedbythe WGM01:0 bits.TOV0 can beusedfor generating a CPU interrupt.
Output Compare Unit The8-bit comparatorcontinuously compares TCNT0 with the Output Compare Register
(OCR0). Whenever TCNT0 equals OCR0, the comparatorsignals amatch.Amatch will
set the Output Compare Flag (OCF0) at thenexttimerclock cycle. If enabled(OCIE0 =
1andGlobalInterrupt Flag in SREG isset), the Output Compare Flag generates an out-
put compareinterrupt. The OCF0 flag is automatically clearedwhen theinterruptis
executed.Alternatively, the OCF0 flag can be clearedbysoftware by writing a logical
onetoitsI/Obit location. The waveform generator uses thematch signal to generate an
output accordingtooperating mode set by the WGM01:0 bits andCompare Output
mode (COM01:0)bits.Themax andbottom signals areusedbythe waveform generator
forhandling the specialcases of theextreme values in some modes of operation. See
“Modes ofOperation” on page 82.
Figure 35 shows a block diagram of the output compare unit.
Figure 35. Output Compare Unit,Block Diagram
OCFn (Int.Req.)
=
(8-bit Comparator )
OCRn
OCn
DATA BUS
TCNTn
WGMn1:0
Waveform Generator
top
FOCn
COMn1:0
bottom
Comentarios a estos manuales