
138
CHAPTER 6
16-BIT TIMER/EVENT COUNTER 0
User’s Manual U12790EJ2V0UD
(3) Pulse width measurement with free-running counter and two capture registers
When 16-bit timer counter 0 (TM0) operates in the free-running mode (refer to Figure 6-19), the pulse widths
of the signals input to the TI00/P32 pin can be measured.
When the edge specified by bits 4 and 5 (ES00 and ES01) of prescaler mode register 0 (PRM0) is input to
the TI00/P32 pin, the value of TM0 is captured to 16-bit capture/compare register 01 (CR01), and an external
interrupt request signal (INTTM01) is set.
The value of TM0 is also captured to 16-bit capture/compare register 00 (CR00) when the reverse edge to
the edge that triggers capturing to the CR01 is input to the pin.
The edge of the TI00/P32 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.
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 prescaler mode register 0 (PRM0), noise with a short pulse width can
be eliminated.
Caution
When both the rising and falling edges are specified as the valid edges of the TI00/P32 pin,
16-bit capture/compare register 00 (CR00) cannot perform a capture operation.
Figure 6-19.
Setting of Control Registers for Measurement with Free-
Running Counter and Two Capture Registers
(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 the descriptions of each control
register.
0000
TMC03
0
TMC02
1
TMC01
0/1
OVF0
0
TMC0
Free-running mode
00000
CRC02
1
CRC01
1
CRC00
1
CRC0
CR00 is used as capture register.
Value of TM0 is captured to CR00 at reverse edge to
valid edge of TI00/P32 pin.
CR01 is used as capture register.