
Chapter 14. Timers/Counters and Serial Interface Page 14-21
To derive the required TH1 value from a known baud rate when T1M=1, use the equation:
Very low serial port baud rates may be achieved with Timer 1 by enabling the Timer 1 interrupt,
configuring Timer 1 to mode 1, and using the Timer 1 interrupt to initiate a 16-bit software reload.
Table 14-15 lists sample reload values for a variety of common serial port baud rates, using Timer
1 operating in mode 2 (TMOD.5:4=10) with a CLKOUT/4 clock source (T1M=1) and the full timer
rollover (SMOD1=1).
More accurate baud rates may be achieved by using Timer 2 as the baud rate generator. To use
Timer 2 as the baud rate generator, configure Timer 2 in auto-reload mode and set the TCLK and/
or RCLK bits in the T2CON SFR. TCLK selects Timer 2 as the baud rate generator for the trans-
mitter; RCLK selects Timer 2 as the baud rate generator for the receiver. The 16-bit reload value
for Timer 2 is stored in the RCAP2L and RCA2H SFRs, which makes the equation for the Timer 2
baud rate:
Table 14-15. Timer 1 Reload Values for Common Serial Port Mode 1 Baud Rates
Nominal
Rate
CLKOUT = 12 MHz CLKOUT = 24 MHz CLKOUT = 48 MHz
TH1
Reload
Value
Actual
Rate
Error
TH1
Reload
Value
Actual
Rate
Error
TH1
Reload
Value
Actual
Rate
Error
57600 FD 62500 +8.50% F9 53571 -6.99% F3 57692 +0.16%
38400 FB 37500 -2.34% F6 37500 -2.34% EC 37500 -2.34%
28800 F9 26786 -6.99% F3 28846 +0.16% E6 28846 +0.16%
19200 F6 18750 -2.34% EC 18750 -2.34% D9 19230 +0.16%
9600 EC 9375 -2.34% D9 9615 +0.16% B2 9615 +0.16%
4800 D9 4807 +0.16% B2 4807 +0.16% 64 4807 +0.16%
2400 B2 2403 +0.16% 64 2403 +0.16% ———
Settings: SMOD=1, C/T
=0, Timer1 Mode=2, T1M=1
Note: Using rates that are off by 2% or more will not work in all systems.
x
TH1 =
2
SMODx
CLKOUT
128 x Baud Rate
256 -
Baud Rate =
32 × (65536 - 256×RCAP2H + RCAP2L)
CLKOUT
Comentarios a estos manuales