Datasheet
rising TOSC1 edge. When waking up from Power-Save mode, and the I/O clock (clk
I/O
) again
becomes active, TCNT2 will read as the previous value (before entering sleep) until the next rising
TOSC1 edge. The phase of the TOSC clock after waking up from Power-Save mode is essentially
unpredictable, as it depends on the wake-up time. The recommended procedure for reading
TCNT2 is thus as follows:
1. Wait for the corresponding update busy flag to be cleared.
2. Read TCNT2.
• During asynchronous operation, the synchronization of the interrupt flags for the asynchronous
timer takes three processor cycles plus one timer cycle. The timer is therefore advanced by at least
one before the processor can read the timer value causing the setting of the interrupt flag. The
output compare pin is changed on the timer clock and is not synchronized to the processor clock.
22.10 Timer/Counter Prescaler
Figure 22-12. Prescaler for TC2
10-BIT T/C PRESCALER
TIMER/COUNTER2 CLOCK SOURCE
I/O
clk
T2S
TOSC1
clk
T2S
/8
clk
T2S
/64
clk
T2S
/128
clk
T2S
/1024
clk
T2S
/256
clk
T2S
/32
0
PSRASY
T2
AS2
CS20
CS21
CS22
Clear
clk
clk
The clock source for TC2 is named clk
T2S
. It is by default connected to the main system I/O clock clk
I/O
.
By writing a '1' to the Asynchronous TC2 bit in the Asynchronous Status Register (ASSR.AS2), TC2 is
asynchronously clocked from the TOSC1 pin. This enables the use of TC2 as a Real Time Counter
(RTC). When AS2 is set, pins TOSC1 and TOSC2 are disconnected from Port B. A crystal can then be
connected between the TOSC1 and TOSC2 pins to serve as an independent clock source for TC2. The
oscillator is optimized for use with a 32.768 kHz crystal.
For TC2, the possible prescaled selections are: clk
T2S
/8, clk
T2S
/32, clk
T2S
/64, clk
T2S
/128, clk
T2S
/256, and
clk
T2S
/1024. Additionally, clk
T2S
, as well as 0 (stop), may be selected. The prescaler is reset by writing a
'1' to the Prescaler Reset TC2 bit in the General TC2 Control Register (GTCCR.PSRASY). This allows
the user to operate with a defined prescaler.
22.11 Register Description
ATmega48PA/88PA/168PA
8-bit Timer/Counter2 (TC2) with PWM and A...
© 2018 Microchip Technology Inc.
Datasheet Complete
DS40002011A-page 212