counting up, the TCFV flag in TSR is set; when underflow occurs while TCNT is counting down,
the TCFU flag is set. The TCFD bit in TSR is the count direction flag. Reading the TCFD flag
provides an indication of whether TCNT is counting up or down. Table 10.19 shows the
correspondence between external clock pins and channels.
Table 10.19 Phase Counting Mode Clock Input Pins
Channels
When channel 1 is set to phase counting mode
When channel 2 is set to phase counting mode
Phase counting mode
Select phase counting mode
<Phase counting mode>
Figure 10.25 Example of Phase Counting Mode Setting Procedure
Example of Phase Counting Mode Setting Procedure: Figure 10.25 shows an example of the
phase counting mode setting procedure.
Examples of Phase Counting Mode Operation: In phase counting mode, TCNT counts up or
down according to the phase difference between two external clocks. There are four modes,
according to the count conditions.
1. Phase counting mode 1
Figure 10.26 shows an example of phase counting mode 1 operation, and table 10.20
summarizes the TCNT up/down-count conditions.
Rev. 3.0, 10/02, page 306 of 686
[1]
[2]
Start count
External Clock Pins
A-Phase
TCLKA
TCLKC
[1]
Select phase counting mode with bits MD3 to
MD0 in TMDR.
[2]
Set the CST bit in TSTR to 1 to start the count
operation.
B-Phase
TCLKB
TCLKD