Setting the Serial Port Baud Rate

For example, with an 11.059MHz crystal, to configure the serial port to 19 200 baud, try plugging it in the first equation:

TH1 = 256 − (( Crystal / 384) / Baud)

TH1 = 256 − ((11 059 000 / 384) / 19 200)

TH1 = 256 − ((28 799) / 19 200)

TH1 = 256 − 1.5 = 254.5

As shown, to obtain 19 200 baud with an 11.059MHz crystal, TH1 would have to be set to 254.5. If it is set to 254, 14 400 baud is achieved and if it is set to 255, 28 800 baud is achieved. This may seem to be an impasse.

However, there is a solution. To achieve 19 200 baud, simply set PCON.7 (SMOD). When this is done, the baud rate is doubled and the second equation mentioned above is used:

TH1 = 256 − (( Crystal / 192) / Baud)

TH1 = 256 − ((11 059 000 / 192) / 19 200)

TH1 = 256 − ((57 699) / 19 200)

TH1 = 256 − 3 = 253

Here, a nice, even TH1 value is calculated. Therefore, to obtain 19 200 baud with an 11.059MHz crystal:

1)Configure Serial Port mode 1 or 3 (for 8-bit or 9-bit serial mode).

2)Configure Timer 1 to timer mode 2 (8-bit auto-reload).

3)Set TH1 to 253 to reflect the correct frequency for 19 200 baud.

4)Set PCON.7 (SMOD) to double the baud rate.

Table 9−5 shows common settings when using Timer 1 to generate the baud rate clock.

Likewise, common settings when using Timer 2 to generate a baud rate clock are indicated in Table 9−6.

Table 9−5. Baud Rate Settings for Timer 1.

Desired Baud

SMOD

 

 

 

Timer

TH1 Value for

TH1 Value for

TH1 Value for

Rate (kb/s)

x

C/T

 

1 Mode

33MHz clk

25MHz clk

11.0592MHz clk

 

 

 

 

 

 

 

 

57.6

1

0

 

2

FDH

FEH

FFH

19.2

1

0

 

2

F7H

F9H

FDH

9.6

1

0

 

2

EEH

F2H

FAH

4.8

1

0

 

2

DCH

E5H

F4H

2.4

1

0

 

2

B8H

CAH

E8H

1.2

1

0

 

2

71H

93H

D0H

9-14

Page 104
Image 104
Texas Instruments MSC1210 manual 5. Baud Rate Settings for Timer, Desired Baud