7902 Group User’s Manual
10-21
TIMER B
10.5 Pulse period/pulse width measurement mode
10.5.2 Operation in pulse period/pulse width measurement mode
When the count start bit is set to “1,” the counter starts counting of the count source.
The counter value is transferred to the reload register when an valid edge of the measurement pulse
is detected. (Refer to section “(1) Pulse period/Pulse width measurement.”)
The counter value is cleared to “000016” after the transfer in , and the counter continues counting.
The timer Bi interrupt request bit is set to “1” when the counter value is cleared to “000016” in (Note).
The interrupt request bit remains set to “1” until the interrupt request is accepted or until the interrupt
request bit is cleared to “0” by software.
The timer repeats operations to above.
Note: No timer Bi interrupt request occurs when the first valid edge is input after the counter starts counting.
(1)
Pulse period/pulse width measurement
The measurement mode select bits (bits 3 and 2 at addresses 5B16 and 5D16) specify whether the
pulse period of an external signal is measured or its pulse width is done. Table 10.5.2 lists the
relationship between the measurement mode select bits and the pulse period/pulse width measurements.
Make sure that the measurement pulse interval from the falling edge to the rising edge, and vice
versa are two cycles of the count source or more. Additionally, use software to identify whether the
measurement result indicates the “H” level width or the “L” level width.
Table 10.5.2 Relationship between measurement mode select bits and pulse period/pulse width
measurements
(2)
Timer Bi overflow flag
A timer Bi interrupt request occurs when a measurement pulse’s valid edge is input or when a
counter overflow occurs. The timer Bi overflow flag is used to identify the source of the interrupt
request occurrence, that is, whether it is an overflow occurrence or a valid edge input.
The timer Bi overflow flag is set to “1” at an overflow occurrence. Accordingly, the source of the
interrupt request occurrence is identified by checking the timer Bi overflow flag in the interrupt
routine. When a value is written to the timer Bi mode register with the count source start bit = “1,”
the timer Bi overflow flag will be cleared to “0” at the next count timing of the count source.
The timer Bi overflow flag is a read-only bit.
Use the timer Bi interrupt request bit to detect the overflow timing. Do not use the timer Bi overflow
flag for this detection.
Figure 10.5.3 shows the operation example during the pulse period measurement, and Figure 10.5.4
shows the operation example during the pulse width measurement.
b3
0
1
Pulse period/Pulse width measurement
Pulse period measurement
Pulse width measurement
Measurement interval (Valid edges)
From falling edge to falling edge (Falling edges)
From rising edge to rising edge (Rising edges)
From falling edge to rising edge, and vice versa
(Falling and rising edges)
b2
0
1
0