Texas Instruments MSC1210 User Manual

Page 98

Advertising
background image

Setting the Serial Port Mode

9-8

The baud rate is adjustable and is based on either Timer 1 or Timer 2. Serial Port
0 can use either Timer 1 or Timer 2, while Serial Port 1 can use only Timer 1.
On an overflow from the timer, a clock is sent to the baud clock. The clock is
divided by 16 to generate the baud clock. The PCON.SMOD0 and
EICON.SMOD1 bits determine whether or not to divide Timer 1 by the rollover
rate of 2. The equation for baud rate is given below:

BaudRate

+

2

SMOD

32

@

Timer1Overflow

It is recommended to use Timer 1 in mode 2 (8-bit counter with auto-reload).
This changes the equation to:

BaudRate

+

2

SMOD

32

@

f

OSC

12

@

(256

*

TH1)

The divide-by-12 can be changed to 4 by setting CKCON.T1M.

To determine the reload value from a given baud rate, use the equation below:

TH1

+

256

*

2

SMOD

@

f

OSC

384

@

BaudRate

You can also achieve very low baud rates from Timer 1 by enabling
T1CON.TF1, configuring the timer for mode 1, and using the timer interrupt to
initiate a 16-bit software reload, as shown in Table 9−2.

Table 9−2. Common Baud Rates Using Timer 1

Baud Rate

SMODx

C/T

Timer 1 Mode

TH1 Value for an

11.0592MHz f

OSC

57.6k

1

0

2

0FF

H

19.2k

1

0

2

0FD

H

9.6k

1

0

2

0FA

H

4.8k

1

0

2

0F4

H

2.4k

1

0

2

0E8

H

1.2k

1

0

2

0D0

H

When using Timer 2 for the baud rate clock, the equation is:

BaudRate

+

Timer2Overflow

16

To use Timer 2 as the baud rate generator, configure Timer 2 in auto-reload
mode and set T2CON.TCLK and T2CON.RCLK (to select Timer 2 as the baud-
rate generator for the transmitter and receiver, respectively). Setting
T2CON.TCLK and T2CON.RCLK will disable the setting of T2CON.TF2 and
the reload on 1-to-0 on T2. The 16-bit reload value is stored in RCAP2L and
RCAP2H, which gives the following equation:

BaudRate

+

f

OSC

32

@

(65536

*

(RCAP2H : RCAP2L))

Advertising