414
Chapter 11
16-bit Timer/Event Counter P (TMP)
Preliminary User’s Manual U17566EE1V2UM00
(c) Processing of overflow when two capture registers are used
Care must be exercised in processing the overflow flag when two capture
registers are used. First, an example of incorrect processing is shown
below.
Figure 11-32
Example of incorrect processing when two capture registers are used
The following problem may occur when two pulse widths are measured in
the free-running timer mode.
<1> Read the TPnCCR0 register (setting of the default value of the TIPn0
pin input).
<2> Read the TPnCCR1 register (setting of the default value of the TIPn1
pin input).
<3> Read the TPnCCR0 register.
Read the overflow flag. If the overflow flag is 1, clear it to 0.
Because the overflow flag is 1, the pulse width can be calculated by
( D
01
-
D
00
).
<4> Read the TPnCCR1 register.
Read the overflow flag. Because the flag is cleared in <3>, 0 is read.
Because the overflow flag is 0, the pulse width can be calculated by
(D
11
-
D
10
) (incorrect).
When two capture registers are used, and if the overflow flag is cleared to
0 by one capture register, the other capture register may not obtain the
correct pulse width.
Use software when using two capture registers. An example of how to use
software is shown below.
FFFFH
16-
b
it co
u
nter
0000H
TPnCE
b
it
TIPn0 pin inp
u
t
TPnCCR0 regi
s
ter
TIPn1 pin inp
u
t
TPnCCR1 regi
s
ter
INTTPnOV
s
ign
a
l
TPnOVF
b
it
D
00
D
01
D
10
D
11
D
10
<1>
<2>
<
3
>
<4>
D
00
D
11
D
01
electronic components distributor