Panasonic MN101C77C User Manual

Page of 544
VII - 37
Chapter 7    16-bit Timer
16-bit Timer Capture
7-9-2
Setup Example
„
Capture Function Setup Example (Timer 7)
Pulse width measurement is enabled by storing the value of the binary counter to the capture register at
the interrupt generation edge of the external interrupt 0 input signal with timer 7. The interrupt generation
edge is specified to be the rising edge.
An example setup procedure, with a description of each step is shown below.
(1) Set the TM7EN flag of the timer 7 mode
register 1 (TM7MD1) to "0" to stop timer 7
counting.
(2) Set the TM7BCR flag of the timer 7 mode
register 2 (TM7MD2) to "1" to select the
compare match as a clear source of binary
counter.
(3) Select fosc as clock source by the TM7CK1-0
flag of the TM7MD1 register. And select 1/1
(no dividing) of fosc as count clock source by
the TM7PS1-0 flag.
(4) Select the external interrupt 0 (IRQ0) input as
a generation source of capture trigger by the
T7ICT1-0 flag of the TM7MD2 register.
(5) Set the REDG0 flag of the external interrupt 0
control register (IRQ0ICR) to "1" to select the
rising edge as the interrupt generation valid
edge.
Setup Procedure
(1) Stop the counter.
TM7MD1 (x'3F78')
bp4
: TM7EN
= 0
(2) Select the condition for timer clear.
TM7MD2 (x'3F79')
bp5
: TM7BCR = 1
(3) Select the count clock source.
TM7MD1 (x'3F78')
bp1-0
: TM7CK1-0 = 00
bp3-2
: TM7PS1-0 = 00
(4) Select the capture trigger generation
interrupt source.
TM7MD2 (x'3F79')
bp1-0
: T7ICT1-0 = 00
(5) Select the interrupt generation valid
edge.
IRQ0ICR (x'3FE2')
bp5
: REDG0
= 1
Description
External interrupt 0
   IRQ 0 input
Pulse width to be measured
interrupt
interrupt
Figure 7-9-3    Pulse Width Measurement of External Interrupt 0