Hardware manual

Common Features Description
Atmel 8051 Microcontrollers Hardware Manual 2-41
4316A–8051–01/04
depending on the system oscillator frequency and the value in the RCAP2H and
RCAP2L registers:
Note: X2 bit is located in the CKCON register.
In X2 mode, F
OSC
=F
XTAL
. In standard mode, F
OSC
=F
XTAL
/2.
For a 16 MHz system clock, timer 2 has a programmable frequency range of 61 Hz
(F
OSC
/2
16)
to 4 MHz (F
OSC
/4). The generated clock signal is brought out to the T2 pin
(P1.0).
Timer 2 is programmed for the clock-out mode as follows:
Set T2OE bit in the T2MOD register.
•Clear C/T2
bit in the T2CON register.
Determine the 16-bit reload value from the formula and enter it in the
RCAP2H/RCAP2L registers.
Enter a 16-bit initial value in timer registers TH2/TL2. It can be the same as the
reload value, or different, depending on the application.
To start the timer, set TR2 run control bit in the T2CON register.
It is possible to use timer 2 as a baud rate generator and a clock generator simulta-
neously. For this configuration, the baud rates and clock frequencies are not
independent since both functions use the values in the RCAP2H and RCAP2L registers.
Figure 2-18. Clock-out Mode
2.12.3 Timer Registers Table 2-11. T2CON Register - T2CON (S:C8h)
Timer 2 Control Register
Clock OutFrequency
F
osc
2
x
2
×
4 65536 RCAP2H RCAP2L()×
---------------------------------------------------------------------------------------- -=
:6
EXF2
TR2
OVER-
FLOW
T2EX
TH2
(8-bit)
TL2
(8-bit)
TIMER 2
RCAP2H
(8-bit)
RCAP2L
(8-bit)
T2OE
T2
FCLK PERIPH
T2CON
T2CON
T2CON
T2MOD
INTERRUPT
QD
Toggle
EXEN2
76543210
TF2 EXF2 RCLK TCLK EXEN2 TR2 C/T2# CP/RL2#