
CHAPTER 7 16-BIT TIMER/EVENT COUNTERS 00 TO 05
User
’
s Manual U15862EJ3V0UD
326
7.4.3 Pulse width measurement
The 16-bit timer counter (TM0n) can be used to measure the pulse widths of the signals input to the TI0n0 and
TI0n1 pins.
Measurement can be carried out with the TM0n register used as a free-running counter or by restarting the timer in
synchronization with the edge of the signal input to the TI0n0 pin.
Setting procedure
The basic operation setting procedure is as follows.
<1> Set the pins to the TI0n0 (or TI0n1) pin mode (see
CHAPTER 4 PORT FUNCTIONS
).
<2> Set the CRC0n register (see
Figures 7-8
,
7-11
,
7-14
,
and
7-16
for the setting value).
<3> Set the count clock using the PRM0n register.
<4> Enable the INTTM0n0 (or INTTM0n1) interrupt (see
CHAPTER 19 INTERRUPT/EXCEPTION
PROCESSING FUNCTION
for details).
<5> Set the TMC0n register: Start operation (see
Figures 7-8
,
7-11
,
7-14
,
and
7-16
for the setting value).
Note
When using two capture registers, set the TI0n0 and TI0n1 pins.
(1) Pulse width measurement with free-running counter and one capture register
If the edge specified by prescaler mode register 0n (PRM0n) is input to the TI0n0 pin when 16-bit timer
counter 0n (TM0n) is operated as a free-running counter (refer to
Figure 7-8
), the value of the TM0n register is
loaded to 16-bit timer capture/compare register 0n1 (CR0n1) and an external interrupt request signal
(INTTM0n1) is set.
The edge is specified by using bits 4 and 5 (ESn00, ESn01) of the PRM0n register. The rising edge, falling
edge, or both the rising and falling edges can be selected.
The valid edge is detected through sampling at a count clock cycle selected with the PRM0n register, and the
capture operation is not performed until the valid edge is detected twice. As a result, noise with a short pulse
width can be eliminated.
Remark
n = 0 to 5