3-3 how to use the baud rate timer – Panasonic MN101C00 User Manual

Page 119

Advertising
background image

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

4.0

fosc

(MHz)

Transfer Speed
(bps)

fosc

fs/4

fs/16

104

Set

Value

Calculated

Value

Set

Value

Calculated

Value

Set

Value

Calculated

Value

Set

Value

Calculated

Value

Set

Value

Calculated

Value

Set

Value

Calculated

Value

300

208

1202

104

2403

52

4807

26

9615

13

19230

109

300

218

1201

109

2402

55

4761

27

9699

208

300

52

1201

208

2404

104

4807

52

9615

26

19230

218

300

55

1190

218

2403

109

4805

55

9523

27

19398

78

300

78

1202

39

2403

156

4808

78

9615

39

19230

104

300

104

1202

52

2404

208

4808

104

9615

52

19230

109

300

109

1201

55

2381

218

4805

109

9610

55

19045

130

300

130

1202

65

2404

33

4735

130

9615

65

19231

fosc

fs/4

fs/16

fosc

fs/4

fs/16

fosc

fs/4

fs/16

fosc

fs/4

fs/16

fosc

fs/4

fs/16

fosc

fs/4

fs/16

fosc

fs/4

fs/16

300

1200

2400

4800

9600

19200

4.19

8.0

8.38

12.0

16.0

16.76

20.0

Set the values from this table

(minus 1) in the compare

register.

Advertising