Bit timer/counter0, Atmega163(l) – Rainbow Electronics ATmega163L User Manual
Page 34

ATmega163(L)
34
sources. Setting the PSR10 bit in SFIOR resets the prescaler. This allows the user to operate with a predictable prescaler.
Note that Timer/Counter1 and Timer/Counter 0 share the same prescaler and a prescaler reset will affect both
Timer/Counters.
Figure 31. Prescaler for Timer/Counter2
The clock source for Timer/Counter2 is named PCK2. PCK2 is by default connected to the main system clock CK. By set-
ting the AS2 bit in ASSR, Timer/Counter2 is asynchronously clocked from the PC6(TOSC1) pin. This enables use of
Timer/Counter2 as a Real Time Clock (RTC). When AS2 is set, pins PC6(TOSC1) and PC7(TOSC2) are disconnected
from Port C. A crystal can then be connected between the PC6(TOSC1) and PC7(TOSC2) pins to serve as an independent
clock source for Timer/Counter2. The oscillator is optimized for use with a 32.768 kHz crystal. Applying an external clock
source to TOSC1 is not recommended. Setting the PSR2 bit in SFIOR resets the prescaler. This allows the user to operate
with a predictable prescaler.
8-bit Timer/Counter0
Figure 32 shows the block diagram for Timer/Counter0.
The 8-bit Timer/Counter0 can select clock source from CK, prescaled CK, or an external pin. In addition it can be stopped
as described in “Timer/Counter0 Control Register - TCCR0” on page 35. The overflow status flag is found in “The
Timer/Counter Interrupt Flag Register - TIFR” on page 29. Control signals are found in the Timer/Counter0 Control Register
- TCCR0. The interrupt enable/disable settings for Timer/Counter0 are found in “The Timer/Counter Interrupt Mask Regis-
ter - TIMSK” on page 28.
When Timer/Counter0 is externally clocked, the external signal is synchronized with the oscillator frequency of the CPU. To
assure proper sampling of the external clock, the minimum time between two external clock transitions must be at least one
internal CPU clock period. The external clock signal is sampled on the rising edge of the internal CPU clock.
The 8-bit Timer/Counter0 features both a high resolution and a high accuracy usage with the lower prescaling opportuni-
ties. Similarly, the high prescaling opportunities make the Timer/Counter0 useful for lower speed functions or exact timing
functions with infrequent actions.
10-BIT T/C PRESCALER
TIMER/COUNTER2 CLOCK SOURCE
CK
PCK2
TOSC1
AS2
CS20
CS21
CS22
PCK2/8
PCK2/64
PCK2/128
PCK2/1024
PCK2/256
PCK2/32
0
PSR2
Clear
TCK2