169
CHAPTER 8 16-BIT TIMER/EVENT COUNTER
User’s Manual U12697EJ3V0UM
(4) Pulse width measurement by restarting
When the valid edge of the TI00/P35 pin is detected, the pulse width of the signal input to the TI00/P35 pin can
be measured by clearing 16-bit timer counter 0 (TM0) once and then resuming counting after loading the count
value of TM0 to 16-bit capture/compare register 01 (CR01) (Refer to
Figure 8-18
).
The edge of the TI00/P35 pin is specified by bits 4 and 5 (ES00 and ES01) of prescaler mode register 0 (PRM0).
The rising or falling edge can be specified.
The valid edge is detected through sampling at a count clock cycle selected by prescaler mode register 0 (PRM0),
and the capture operation is not performed until the valid level is detected two times. Therefore, noise with a
short pulse width can be rejected.
Caution If the valid edge of the TI00/P35 pin is specified to be both the rising and falling edges,
capture/compare register 00 (CR00) cannot perform its capture operation.
Figure 8-18. Control Register Settings for Pulse Width Measurement by Restarting
(a) 16-bit timer mode control register 0 (TMC0)
0
0
0
0
TMC03
1
TMC02
0
TMC01
0/1
OVF0
0
TMC0
Clears and starts at valid edge of TI00/P35 pin.
(b) Capture/compare control register 0 (CRC0)
0
0
0
0
0
CRC02
1
CRC01
1
CRC00
1
CRC0
CR00 as capture register
Captures to CR00 at edge reverse to
valid edge of TI00/P35 pin.
CR01 as capture register
Remark
0/1:
When these bits are reset to 0 or set to 1, the other functions can be used along with the pulse
measurement function. For details, refer to
Figures 8-2
and
8-3
.