Panasonic F77G, MN101C77C user manual IRQ2ICR, REDG2

Models: F77G MN101C77C

1 544
Download 544 pages 59.61 Kb
Page 251
Image 251

Chapter 6 8-bit Timers

6-9-2 Setup Example

„Set up Example of Simple Pulse Width Measurement by 8-bit Timer (Timers 0, 4 and 5)

The pulse width of 'L" period of the external interrupt 2 (IRQ2) input signal is measured by timer 0. The clock source of timer 0 is selected to fosc.

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 stop timer 0 counting.

 

bp3

:TM0EN

= 0

 

 

 

(2)

Set the pulse width measurement

(2)

Set the TM0PWM flag of the TM0MD register

 

operation.

 

 

 

to "0" and TM0MOD flag to "1" to enable the

 

TM0MD (x'3F54')

 

 

timer operation during "L" period to be

 

bp4

:TM0PWM

= 0

 

measured.

 

bp5

:TM0MOD

= 1

 

 

 

(3)

Select the count clock source.

(3)

Set the clock source to fosc by the TM0CK2-0

 

TM0MD (x'3F54')

 

 

flag of the TM0MD register.

 

bp2-0

: TM0CK2-0 = 000

 

 

 

(4)

Set the compare register.

 

(4)

Set the timer 0 compare register (TM0OC) to

 

TM0OC (X'3F52')

= x'FF'

 

the bigger value than ("L"period of measured

 

 

 

 

 

pulse width / the cycle of fosc).

 

 

 

 

 

At that time, the timer 0 binary counter

 

 

 

 

 

(TM0BC) is initialized to x'00'.

(5)

Set the interrupt level

 

(5)

Set the interrupt level by the IRQ2LV1-0 flag

 

IRQ2ICR (x'3FE4')

 

 

of the external interrupt 2 control register

 

bp7-6

:IRQ2LV1-0 = 10

 

(IRQ2ICR).

 

 

 

 

 

If interrupt request flag is already set, clear all

 

 

 

 

 

interrupt request flags.

 

 

 

 

 

[

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

(6)

Set the interrupt valid edge.

(6)

Set the REDG2 flag of the IRQ2ICR register to

 

IRQ2ICR (x'3FE4')

 

 

"1" to specify the interrupt valid edge to the

 

bp5

:REDG2

= 1

 

rising edge.

 

 

 

 

 

 

 

Simple Pulse Width Measurement VI - 37

Page 251
Image 251
Panasonic F77G, MN101C77C user manual IRQ2ICR, REDG2