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

 

 

 

 

Transfer Speed

300

1200

2400

4800

9600

19200

fosc

(bps)

Set

Calculated

Set

Calculated

Set

Calculated

Set

Calculated

Set

Calculated

Set

Calculated

(MHz)

 

 

Value

Value

Value

Value

Value

Value

Value

Value

Value

Value

Value

Value

4.0

fosc

208

1202

104

2403

52

4807

26

9615

13

19230

fs/4

104

300

 

fs/16

4.19

fosc

218

1201

109

2402

55

4761

27

9699

fs/4

109

300

 

fs/16

8.0

fosc

208

2404

104

4807

52

9615

26

19230

fs/4

208

300

52

1201

 

fs/16

8.38

fosc

218

2403

109

4805

55

9523

27

19398

fs/4

218

300

55

1190

 

fs/16

 

fosc

156

4808

78

9615

39

19230

12.0

fs/4

78

1202

39

2403

 

fs/16

78

300

16.0

fosc

208

4808

104

9615

52

19230

fs/4

104

1202

52

2404

 

fs/16

104

300

16.76

fosc

218

4805

109

9610

55

19045

fs/4

109

1201

55

2381

 

fs/16

109

300

20.0

fosc

130

9615

65

19231

fs/4

130

1202

65

2404

33

4735

 

fs/16

130

300

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 106/2/4)/(300 2 8) – 1

=207

= X'CF'

Chapter 5 Serial Functions

Set the values from this table

(minus 1) in the compare

register.

Half-duplex UART Serial Interface 105

Page 119
Image 119
Panasonic MN101C00 user manual How to Use the Baud Rate Timer