CHAPTER 6 16-BIT TIMER/EVENT COUNTER P (TMP)
User’s Manual U16896EJ2V0UD
210
(2/2)
Example when two capture registers are used (without using overflow interrupt)
FFFFH
16-bit counter
0000H
TP0CE bit
INTTP0OV signal
TP0OVF bit
TP0OVF0 flag
Note
TIP00 pin input
TP0CCR0 register
TP0OVF1 flag
Note
TIP01 pin input
TP0CCR1 register
D
10
D
11
D
00
D
01
D
10
<1>
<2>
<5> <6>
<3>
<4>
D
00
D
11
D
01
Note
The TP0OVF0 and TP0OVF1 flags are set on the internal RAM by software.
<1> Read the TP0CCR0 register (setting of the default value of the TIP00 pin input).
<2> Read the TP0CCR1 register (setting of the default value of the TIP01 pin input).
<3> An overflow occurs. Nothing is done by software.
<4> Read the TP0CCR0 register.
Read the overflow flag. If the overflow flag is 1, set only the TP0OVF1 flag to 1, and clear the
overflow flag to 0.
Because the overflow flag is 1, the pulse width can be calculated by ( D
01
−
D
00
).
<5> Read the TP0CCR1 register.
Read the overflow flag. Because the overflow flag is cleared in <4>, 0 is read.
Read the TP0OVF1 flag. If the TP0OVF1 flag is 1, clear it to 0.
Because the TP0OVF1 flag is 1, the pulse width can be calculated by ( D
11
−
D
10
)
(correct).
<6> Same as <3>