8-2 setup example – Panasonic MN101C77C User Manual

Page 248

Advertising
background image

Chapter 6 8-bit Timers

VI - 34

Serial Transfer Clock Output

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.

(1)

Set the TM4EN flag of the timer 4 mode

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

counting.

(2)

Set the TM4PWM flag and TM4MOD flag of

the TM4MD register to "0" to select the normal

timer operation.

(3)

Select the clock source to prescaler output by

the TM4CK2-0 flag of the TM4MD register.

(4)

Select the prescaler output to fs/4 by the

TM4PSC1-0, TM4BAS flag of the timer 4

prescaler selection register (CK4MD).

Also, set the PSCEN flag of the prescaler

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

prescaler counting.

(5)

Set the timer 4 compare register (TM4OC) to

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)

Set the TM4EN flag of the TM4MD register to

"1" to start timer 4.

Setup Procedure

(1)

Stop the counter.

TM4MD (x'3F64')

bp3

:TM4EN

= 0

(2)

Select the normal timer operation.

TM4MD (x'3F64')

bp4

:TM4PWM = 0

bp5

:TM4MOD

= 0

(3)

Select the count clock source.

TM4MD (x'3F64')

bp2-0

:TM4CK2-0 = 001

(4)

Select the prescaler output and

enable counting.

CK4MD (x'3F66')

bp2-1

:TM4PSC1-0 = 01

bp0

:TM4BAS

= 1

PSCMD (x'3F6F')

bp0

:PSCEN

= 1

(5)

Set the baud rate.

TM4OC (x'3F62')

= x'CF'

(6)

Start the timer operation

TM4MD (x'3F64')

bp3

:TM4EN

= 1

Description

Advertising
This manual is related to the following products: