
CHAPTER 8 TIMER 0
196
8.7.2 Pulse width measurement operation
In pulse width measurement, the high-level or low-level width of external pulses input to the external interrupt request
input pin (INTP0 through INTP3) is measured.
When the sampling clock is f
CLK
both the high-level and low-level widths of pulses input to the INTPn (n = 0 to 3) pin must
be at least 4 system clocks (0.25
m
s: f
CLK
= 16 MHz); if shorter than this, the valid edge will not be detected and a capture
operation will not be performed.
When a pulse width is measured, the pulse width in a range shown in Table 8-2 can be measured (f
CLK
= 16 MHz). How
a pulse width is measured is explained below where the INTP3 pin is used as an external input pin.
As shown in Figure 8-17, the timer register 0 (TM0) value being counted is fetched into the capture register (CC03) in
synchronization with a valid edge (specified as both rising and falling edges) in the INTP3 pin input, and held there. The
pulse width is obtained from the product of the difference between the TM0 count value (Dn) fetched into and held in the
CC03 on detection of the nth valid edge and the count value (D
n-1
) fetched and held on detection of valid edge n-1, and
the number of count clocks (x/f
CLK
; x = 4, 8, 16, 32, 64).
The control register settings are shown in Figure 8-18, the setting procedure in Figure 8-19, and the processing at interrupt
processing routine in Figure 8-20.
Figure 8-17. Timing of Pulse Width Measurement
Remark
Dn: TM0 count value (n = 0, 1, 2, ...)
x = 4, 8, 16, 32, 64
D1
INTP3
External Input Signal
INTP3
Interrupt Request
TM0
Count Value
0H
FFFFH
Capture Register
(CC03)
INTOV0
Interrupt Request
D0
D0
D1
Count Started
FFFFH
D2
D2
D3
Capture
Capture
Capture
Capture
(D1_D0)
×
x/f
CLK
(10000H_D1+
D2)
×
x/f
CLK
(D3_D2)
×
x/f
CLK
D3