CMOS single-chip 8-bit microcontrollers
NOTE: OSC. Freq. is divided by 2, not 12.
C/T2 = 0
C/T2 = 1
Note availability of additional external interrupt.
Figure 4. Timer 2 in Baud Rate Generator Mode
Table 2. Timer 2 Operating Modes
RCLK + TCLK
Baud rate generator
Timer 2 as a baud rate generator is shown in Figure 4. This figure is
valid only if RCLK + TCLK = 1 in T2CON. Note that a rollover in TH2
does not set TF2, and will not generate an interrupt. Therefore, the
Timer 2 interrupt does not have to be disabled when Timer 2 is in
the baud rate generator mode. Note too, that if EXEN2 is set, a
1-to-0 transition in T2EX will set EXF2 but will not cause a reload
from (RCAP2H, RCAP2L) to (TH2, TL2). Thus when Timer 2 is in
use as a baud rate generator, T2EX can be used as an extra
external interrupt, if desired.
It should be noted that when Timer 2 is running (TR2 = 1) in “timer”
function in the baud rate generator mode, one should not try to read
or write TH2 or TL2. Under these conditions the timer is being
incremented every state time, and the results of a read or write may
not be accurate. The RCAP registers may be read, but should not
be written to, because a write might overlap a reload and cause
write and/or reload errors. Turn the timer off (clear TR2) before
accessing the Timer 2 or RCAP registers, in this case.
Timer/Counter 2 Set-up
Except for the baud rate generator mode, the values given for
T2CON do not include the setting of the TR2 bit. Therefore, bit TR2
must be set, separately, to turn the timer on. See Table 3 for set-up
of timer 2 as a timer. See Table 4 for set-up of timer 2 as a counter.
Using Timer/Counter 2 to Generate Baud Rates
For this purpose, Timer 2 must be used in the baud rate generating
mode. If Timer 2 is being clocked through pin T2 (P1.0) the baud
And if it is being clocked internally, the baud rate is:
Baud Rate + 32
[65536 * (RCAP2H, RCAP2L)]
To obtain the reload value for RCAP2H and RCA02L, the above
equation can be rewritten as:
32 Baud Rate
1996 Aug 16