
78
ATmega8515(L)
2512A–AVR–04/02
inactive when no clock sourceisselected.Theoutput from the clock select logic is
referred to as thetimerclock (clk
T0
).
The double bufferedOutput CompareRegister(OCR0) iscomparedwith the
Timer/Counter value at all times.The resultof the compare can beusedbythe Wave-
form Generator to generateaPWM or variable frequency output on the Output Compare
Pin (OC0). See “Output Compare Unit” on page 79. fordetails.The comparematch
event will also set the Compare Flag (OCF0)which can beused to generate an output
compareinterrupt request.
Definitions Manyregister andbit references in thisdocument are written in generalform. A lower
case“n”replaces theTimer/Counter number, in thiscase0.However, when using the
register orbit defines in a program, the precise formmust beused, i.e., TCNT0 for
accessing Timer/Counter0 counter value andso on.
The definitions in Table43 arealsoused extensively throughout the document.
Timer/Counter Clock
Sources
TheTimer/Countercan be clockedbyan internal or an externalclock source. The clock
sourceisselectedbythe clock select logicwhich iscontrolledbythe Clock Select
(CS02:0)bitslocated in theTimer/CounterControl Register(TCCR0). Fordetails on
clock sources andprescaler, see “Timer/Counter0and Timer/Counter1Prescalers”on
page 92.
Counter Unit Themainpartof the8-bit Timer/Counter is the programmable bi-directionalcounter unit.
Figure 34 shows a block diagram of the counter and itssurroundings.
Figure 34. CounterUnit Block Diagram
Signaldescription (internalsignals):
count Increment ordecrement TCNT0 by 1.
direction Select between increment anddecrement.
clear Clear TCNT0 (set all bits to zero).
Table 43. Definitions
BOTTOM The counterreaches the BOTTOM when it becomes 0x00.
MAX The counterreaches itsMAXimum when it becomes 0xFF (decimal 255).
TOPThe counterreaches theTOP when it becomes equal to the highest
value in the count sequence. TheTOPvalue can beassigned to bethe
fixed value 0xFF (MAX) or thevalue stored in the OCR0 Register.The
assignment isdependent on themodeof operation.
DATA B U S
TCNTn Control Logic
count
TOVn
(Int.Req.)
Clock Select
top
Tn
Edge
Detector
( From Prescaler )
clk
Tn
bottom
direction
clear
Kommentare zu diesen Handbüchern