Panasonic MN101C77C, F77G user manual TM4EN, TM4PWM, TM4MOD, TM4BAS

Models: F77G MN101C77C

1 544
Download 544 pages 59.61 Kb
Page 248
Image 248

Chapter 6 8-bit Timers

6-8-2 Setup Example

„Serial Interface Transfer Clock Setup Example (Timer 4)

How to create a transfer clock for half duplex UART (Serial interface 1) using with timer 4 is shown below. The baud rate is selected to be 300 bps, the source clock of timer 4 is selected to be fs/4 (at fosc=8 MHz).

An example setup procedure, with a description of each step is shown below.

 

Setup Procedure

 

 

 

Description

 

 

 

 

 

(1)

Stop the counter.

 

(1)

Set the TM4EN flag of the timer 4 mode

 

TM4MD (x'3F64')

 

 

register (TM4MD) to "0" to stop timer 4

 

bp3

:TM4EN

= 0

 

counting.

 

(2)

Select the normal timer operation.

(2)

Set the TM4PWM flag and TM4MOD flag of

 

TM4MD (x'3F64')

 

 

the TM4MD register to "0" to select the normal

 

bp4

:TM4PWM

= 0

 

timer operation.

 

bp5

:TM4MOD

= 0

 

 

 

(3)

Select the count clock source.

(3)

Select the clock source to prescaler output by

 

TM4MD (x'3F64')

 

 

the TM4CK2-0 flag of the TM4MD register.

 

bp2-0

:TM4CK2-0 = 001

 

 

 

(4)

Select the prescaler output and

(4)

Select the prescaler output to fs/4 by the

 

enable counting.

 

 

TM4PSC1-0, TM4BAS flag of the timer 4

 

CK4MD (x'3F66')

 

 

prescaler selection register (CK4MD).

 

bp2-1

:TM4PSC1-0 = 01

 

Also, set the PSCEN flag of the prescaler

 

bp0

:TM4BAS

= 1

 

control register (PSCMD) to "1" to enable the

 

PSCMD (x'3F6F')

 

 

prescaler counting.

 

bp0

:PSCEN

= 1

 

 

 

(5)

Set the baud rate.

 

(5)

Set the timer 4 compare register (TM4OC) to

 

TM4OC (x'3F62')

= x'CF'

 

the value that baud rate comes to 300 bps.

 

 

 

 

 

[

Chapter 12. Table 12-3-19 ]

 

 

 

 

 

At that time, the timer 4 binary counter

 

 

 

 

 

(TM4BC) is initialized to x'00'.

(6)

Start the timer operation

 

(6)

Set the TM4EN flag of the TM4MD register to

 

TM4MD (x'3F64')

 

 

"1" to start timer 4.

 

bp3

:TM4EN

= 1

 

 

 

 

 

 

 

 

 

 

VI - 34 Serial Transfer Clock Output

Page 248
Image 248
Panasonic MN101C77C, F77G user manual TM4EN, TM4PWM, TM4MOD, TM4BAS