beautypg.com

Texas Instruments MSC1210 User Manual

Page 104

background image

Setting the Serial Port Baud Rate

9-14

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

Rate (kb/s)

SMOD

x

C/T

Timer

1 Mode

TH1 Value for

33MHz clk

TH1 Value for

25MHz clk

TH1 Value for

11.0592MHz clk

57.6

1

0

2

FD

H

FE

H

FF

H

19.2

1

0

2

F7

H

F9

H

FD

H

9.6

1

0

2

EE

H

F2

H

FA

H

4.8

1

0

2

DC

H

E5

H

F4

H

2.4

1

0

2

B8

H

CA

H

E8

H

1.2

1

0

2

71

H

93

H

D0

H