Panasonic F77G, MN101C77C user manual P1DIR1, TM0ICR

Models: F77G MN101C77C

1 544
Download 544 pages 59.61 Kb
Page 235
Image 235

Chapter 6 8-bit Timers

6-4-2 Setup Example

„Event Count Setup Example (Timers 0, 1, 4 and 5)

If the falling edge of the TM0IO input pin signal is detected 5 times with using timer 0, an interrupt is generated.

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 input.

(2) Set the P1DIR1 flag of the port 1 direction

 

 

P1DIR (x'3F31')

 

control register (P1DIR) to "0" to set P11 pin to

 

 

bp0

:P1DIR1

= 0

input mode.

 

 

 

 

 

If it needs, pull up resistor 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 the clock source to TM0IO input by the

 

 

TM0MD (x'3F54')

 

TM0CK2-0 flag of the TM0MD register.

 

 

bp2-0

:TM0CK2-0 = 110

 

 

 

(5)

Set the interrupt generation cycle.

(5) Set the timer 0 compare register (TM0OC) the

 

 

TM0OC (x'3F52')

= x'04'

interrupt generation cycle. Counting is 5, so

 

 

 

 

 

the setting value should be 4.

 

 

 

 

 

At that time, the timer 0 binary counter

 

 

 

 

 

(TM0BC) is initialized to x'00'.

 

(6)

Set the interrupt level.

 

(6) Set the interrupt level by the TM0LV1-0 flag

 

 

TM0ICR (x'3FE9')

 

of the timer 0 interrupt control register

 

 

bp7-6

:TM0LV1-0

= 10

(TM0ICR).

 

 

 

 

 

If the interrupt request flag may be already set,

 

 

 

 

 

cancel all existing interrupt requests.

 

 

 

 

 

[

Chapter 3 3-1-4. Interrupt Flag Setup ]

 

 

 

 

 

 

 

8-bit Event Count VI - 21

Page 235
Image 235
Panasonic F77G, MN101C77C user manual P1DIR1, TM0ICR