
125
CHAPTER 7 16-BIT TIMER/EVENT COUNTER
User
’
s Manual U15017EJ2V0UD
7.4.2 Pulse width measurement
16-bit timer counter 0 (TM0) can be used to measure the pulse widths of the signals input to the TI00/P20 and
TIO51/P66 pins.
Measurement can be carried out with TM0 used as a free-running counter or by restarting the timer in
synchronization with the edge of the signal input to the TI00/P20 pin.
(1) Pulse width measurement with free running counter and one capture register
If the edge specified by prescaler mode register 0 (PRM0) is input to the TI00/P20 pin when 16-bit timer counter
0 (TM0) is used as a free-running counter (refer to
Figure 7-9
), the value of TM0 is loaded to 16-bit capture/
compare register 01 (CR01), and an external interrupt request signal (INTTM01) is set.
The edge is specified by using bits 4 and 5 (ES00 and ES01) of PRM0. The rising edge, falling edge, or both
the rising and falling edges can be selected.
Sampling is performed with the count clock selected by PRM0, and the capture operation is performed when the
valid level of the TI00 pin is detected two times. Therefore, noise with a short pulse width can be eliminated.
Figure 7-9.
Control Register Settings for Pulse Width Measurement with
Free-Running Counter and One Capture Register
(a) 16-bit timer mode control register (TMC0)
(b) Capture/compare control register 0 (CRC0)
0
0
0
0
TMC03
0
TMC02
1
0
OVF0
0
TMC0
Free-running mode
0
0
0
0
0
CRC02
1
CRC01
0/1
CRC00
0
CRC0
CR00 as compare register
CR01 as capture register