5-3-3 How to Use the Baud Rate Timer
Refer to the following when using the baud rate timer to set the UART transfer
speed.
(1) Specifying the timer clock source
The clock source is specified by the TM3CKS3 to 1 flags of the timer 3
mode register (TM3MD).
(2) Setting the compare register
The compare register value is set in the timer 3 compare register (TM3OC).
This set value is computed according to the following formula:
overflow period = (compare register set value + 1) × timer clock period
baud rate = 1/(overflow period × 2 × 8)
↑ SC0MD1(SC0CKM)
compare register set value = timer clock frequency/(baud rate × 2 × 8) – 1
Table 5-3-1 UART Transfer Rate
Example:
The timer 3 clock source is fs/4 (fosc = 8MHz) and a baud rate of 300 bps is
desired.
Since fs=fosc/2,
compare register set value = (8 × 10
6
/2/4)/(300 × 2 × 8) – 1
=207
= X'CF'
Chapter 5 Serial Functions
105
Half-duplex UART Serial Interface