
134
CHAPTER 6
16-BIT TIMER/EVENT COUNTER 0
User’s Manual U12790EJ2V0UD
6.4.3 Pulse width measurement
16-bit timer counter 0 can be used to measure the pulse width of the signal input to the TI00/P32 and TI01/P33
pins.
The pulse width can be measured by operating TM0 in the free-running mode, or by restarting the timer in
synchronization with the edge of the signal input to the TI00/P32 pin.
(1) Pulse width measurement with free-running counter and one capture register
When 16-bit timer counter 0 (TM0) operates in the free-running mode (refer to the register setting in Figure
6-13) and if the edge specified by prescaler mode register 0 (PRM0) is input to the TI00/P32 pin, the value
of TM0 is loaded to 16-bit capture/compare register 01 (CR01) and an external interrupt request signal
(INTTM01) is set.
The rising, falling, or both the rising and falling edges can be selected as the edge by using bits 6 and 7 (ES10
and ES11) of PRM0.
Because the value of TM0 is captured only after the valid level of the TI00 pin is detected twice by sampling
using the count clock cycle selected by PRM0, noise with a short pulse width can be eliminated.
Figure 6-13. Setting of Control Registers for Pulse Width Measurement
with Free-Running Counter and One Capture Register
(a) 16-bit timer mode control register 0 (TMC0)
(b) Capture/compare control register 0 (CRC0)
Remark
0/1: When these bits are set to 1 or reset to 0, other functions can be used at the same time as
the pulse width measurement function. For details, refer to Figures 6-2 and 6-3.
0000
TMC03
0
TMC02
1
TMC01
0/1
OVF0
0
TMC0
Free-running mode
00000
CRC02
1
CRC01
0/1
CRC00
0
CRC0
CR00 is used as compare register.
CR01 is used as capture register.