Panasonic MN101C00 User Manual

Page 89

Advertising
background image

Chapter 4 Timer Functions

75

16-bit Timer Operation (timer 4)

■ Capture Function

Settings for the capture function are listed below.

(1)

Set the TM4EN flag of the timer 4 mode register (TM4MD) to "0" to stop the count

operation of timer 4.

(2)

Use the TM4CK2 to 0 flags of the TM4MD register to select fosc, fs/4, or fs/16 as the

clock source.

(3)

Use the T4ICTS1 and T4ICTS0 flags of the TM4MD register to select IRQ2,

IRQ1, or IRQ0 as the input capture trigger.

(4)

Set the REDGn flag of the external interrupt control register to specify the valid edge

for the interrupt selected as the TM4 input capture trigger.

(5)

Set the TM4PWM flag of the TM4MD register to "1" to select 16-bit timer

operation.

(6)

Set a value in compare register 4 (TM4OCH, TM4OCL).

(7)

Set the TM4EN flag of the TM4MD register to "1" to start the timer.

(8)

When timer 4 begins operation, binary counter 4 will count upward from X'0000'

until it reaches the value set in compare register 4.

(9)

If the binary counter is to be used as a free-running counter that counts from

X'0000' to X'FFFF', set the compare register 4 to X'FFFF'.

When the value of binary counter 4 matches that of the TM4OCH, TM4OCL

register, the timer 4 interrupt request flag is set, binary counter 4 is reset to X'0000',

and counting begins again.

(10)

If the external interrupt selected as the TM4 input capture trigger is received during

timer 4 operation, the value of binary counter 4 will be written into the input capture

register (TM4ICH, TM4ICL).

Setting a value in compare register

4, clears binary counter 4.

If the event occurs before a read,

that data will be overwritten.

Advertising