Mode 2, Mode 1 or 3 – Maxim Integrated High-Speed Microcontroller User Manual
Page 142

High-Speed Microcontroller User’s Guide
Rev: 062210
142 of 176
Note that the 12 in the denominator can be changed to a 4 as determined by the timer selection (T1M;
.4). This formula provides the derived baud rate for a given TH1 and crystal. Most users already
know what baud rate is desired and want the timer reload value. Thus the equation solves as follows,
when T1M = 0.
2
SMOD_x
x Oscillator Frequency
TH1 = 2 32 x 12 x Baud Rate
Note that the most common application is to use Timer 1 in 8-bit auto-reload mode as a timer. It can
actually be used in any mode and can also be configured as a counter.
To use Timer 2 as baud rate generator for Serial Port 0, the Timer is configured in auto-reload mode.
Then either TCLK or RCLK bit (or both) are set to a logic 1. TCLK = 1 selects Timer 2 as the baud-rate
generator for the transmitter and RCLK = 1 selects Timer 2 for the receiver. Thus, Serial Port 0 can have
the transmit and receive operating at different baud rates by choosing 1 for one data direction and Timer 2
for the other. Setting either RCLK or TCLK to a logic 1 selects Timer 2 for baud-rate generation. RCLK
and TCLK reside in
.4 and
.5, respectively.
When using Timer 2 to generate baud rates, the formula will be as follows. Note that the reload value is a
16-bit number as compared with Timer 1, which uses only 8 bits.
o
Mode 1, 3 Baud Rate =
RCAP2L)
RCAP2H,
(65,536
x
32
Frequency
Oscillator
Note that the 32 in the denominator is a result of the timer being run at a divide-by-2, combined with the
divide
-
by-16 applied to timer overflows as mentioned above. Timer 2 normally runs at a divide by either
12 or 4 in auto-reload mode. Setting RCLK or TCLK causes the divide-by-2 operation.
This formula provides the derived baud rate for a given RCAP2H, RCAP2L and crystal. Most users
already know what baud rate is desired and want the timer reload value. Thus the equation solves as
follows.
RCAP2H, RCAP2L = 65,536 –
Rate
Baud
x
32
Frequency
Oscillator
The Timer 2 interrupt is automatically disabled when either RCLK or TCLK is set. Also, the TF2
(
.7) flag will not be set on a timer rollover. The manual reload pin [T2EX (P1.1)] will not cause a
reload either.