(2) Measuring the pulse width by using one input signal of the TI00n pin (free-running mode)
Set the free-running timer mode (TMC0n3 and TMC0n2 = 01). The count value of TM0n is captured to CR00n in
the phase reverse to the valid edge detected on the TI00n pin. When the valid edge of the TI00n pin is detected,
the count value of TM0n is captured to CR01n.
By this measurement method, values are stored in separate capture registers when a width from one edge to
another is measured. Therefore, the capture values do not have to be saved. By subtracting the value of one
capture register from that of another, a high-level width, low-level width, and cycle are calculated.
If an overflow occurs, the value becomes negative if one captured value is simply subtracted from another and,
therefore, a borrow occurs (bit 0 (CY) of the program status word (PSW) is set to 1). If this happens, ignore CY
and take the calculated value as the pulse width. In addition, clear bit 0 (OVF0n) of 16-bit timer mode control
register 0n (TMC0n) to 0.
Figure 7-54. Timing Example of Pulse Width Measurement (2)
FFFFH
TM0n register
0000H
Operable bits
(TMC0n3, TMC0n2)
Capture trigger input
(TI00n)
Capture register
(CR00n)
Capture register
(CR01n)
Capture interrupt
(INTTM01n)
Overflow flag
(OVF0n)
Capture trigger input
(TI01n)
Compare match interrupt
(INTTM00n)
CHAPTER 7 16-BIT TIMER/EVENT COUNTERS 00 AND 01
• TMC0n = 04H, PRM0n = 10H, CRC0n = 07H
M
A
B
01
Preliminary User's Manual U17260EJ3V1UD
N
S
C
P
D
E
233