Panasonic MN101C77C, F77G user manual P1OMD0, P1DIR0

Models: F77G MN101C77C

1 544
Download 544 pages 59.61 Kb
Page 238
Image 238

Chapter 6 8-bit Timers

6-5-2 Setup Example

„Timer Pulse Output Setup Example (Timers 0, 1, 4 and 5)

TM0IO (P10) pin outputs 50 kHz pulse by using timer 0. For this, select fosc as clock source, and set a 1/ 2 cycle (100 kHz) for the timer 0 compare register (at fosc=20 MHz).

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

 

Setup Procedure

 

 

 

Description

 

 

 

 

 

(1)

Stop the counter.

 

(1)

Set the TM0EN flag of the timer 0 mode

 

TM0MD (x'3F54')

 

 

register (TM0MD) to "0" to stop timer 0

 

bp3

:TM0EN

= 0

 

counting.

(2)

Set the special function pin to the

(2)

Set the P1OMD0 flag of the port 1 output mode

 

output mode.

 

 

 

register (P1OMD) to "1" to set P10 the special

 

P1OMD (x'3F2F')

 

 

function pin.

 

bp0

:P1OMD0

= 1

 

Set the P1DIR0 flag of the port 1 direction

 

P1DIR (x'3F31')

 

 

control register (P1DIR) to "1" to set output

 

bp0

:P1DIR0

= 1

 

mode.

 

 

 

 

 

If it needs, pull-up resister should be added.

 

 

 

 

 

[

Chapter 4. I/O Ports ]

(3)

Select the normal timer operation.

(3)

Set the TM0PWM flag and TM0MOD flag of

 

TM0MD (x'3F54')

 

 

the TM0MD register to "0" to select the normal

 

bp4

:TM0PWM

= 0

 

timer operation.

 

bp5

:TM0MOD

= 0

 

 

 

(4)

Select the count clock source.

(4)

Select fosc for the clock source by the

 

TM0MD (x'3F54')

 

 

TM0CK2-0 flag of the TM0MD register.

 

bp2-0

:TM0CK2-0 = 000

 

 

 

(5)

Set the timer pulse output cycle.

(5)

Set the timer 0 compare register (TM0OC) to

 

TM0OC (x'3F52')

= x'C7'

 

the 1/2 of the timer pulse output cycle.

 

 

 

 

 

The setting value should be 200-1=199(x'C7'),

 

 

 

 

 

because 100 kHz is divided by 20 MHz.

 

 

 

 

 

At that time, the timer 0 binary counter

 

 

 

 

 

(TM0BC) is initialized to x'00'.

(6)

Start the timer operation.

 

(6)

Set the TM0EN flag of the TM0MD register to

 

TM0MD (x'3F54')

 

 

"1" to start timer 0.

 

bp3

:TM0EN

= 1

 

 

 

 

 

 

 

 

 

 

VI - 24 8-bit Timer Pulse Output

Page 238
Image 238
Panasonic MN101C77C, F77G user manual P1OMD0, P1DIR0