RX610 Group
15. 16-Bit Timer Pulse Unit (TPU)
R01UH0032EJ0120 Rev.1.20
Page 503 of 1006
Feb 20, 2013
15.3.6
Phase Counting Mode
In phase counting mode, the phase difference between two external clock inputs is detected by the settings for channels 1,
2, 4, and 5 (unit 0) and channels 7, 8, 10, and 11 (unit 1), and TPUm.TCNT is incremented/decremented accordingly.
When phase counting mode is set, an external clock is selected as the counter input clock and TCNT operates as an
up-/down-counter regardless of the setting of the TPSC[2:0] bits and CKEG[1:0] bits in TPUm.TCR. However, the lower
2 bits of the CCLR[2:0] bits in TPUm.TCR and the functions of TPUm.TIORH, TPUm.TIORL, TPUm.TIOR,
TPUm.TIER, and TPUm.TGRy are valid, and therefore input capture/compare match and interrupt functions are
available.
This can be used for two-phase encoder pulse input.
When an overflow occurs while TCNT is counting up, a TCIV interrupt request is generated; when an underflow occurs
while TCNT is counting down, a TCIU interrupt request is generated. The TCFD bit in TPUm.TSR is the count direction
flag. Reading the TCFD flag provides an indication of whether TCNT is counting up or down.
Table 15.26 shows the correspondence between external clock pins and channels.
Table 15.26 Clock Input Pins in Phase Counting Mode
Unit
Channel
External Clock Pins
A-Phase
B-Phase
0
When TPU1 or TPU5 is set to phase counting mode
TCLKA
TCLKB
When TPU2 or TPU4 is set to phase counting mode
TCLKC
TCLKD
1
When TPU7 or TPU11 is set to phase counting mode
TCLKE
TCLKF
When TPU8 or TPU10 is set to phase counting mode
TCLKG
TCLKH
(1)
Example of Phase Counting Mode Setting Procedure
Figure 15.25 shows an example of the phase counting mode setting procedure.
Select phase counting mode
Phase counting mode
Start counting
<Phase counting mode>
[1]
[2]
Select phase counting mode with the
MD[3:0] bits in TMDR.
[1]
Set the CSTj bit in TSTRy to 1 to start
count operation (y = A, B, j = 0 to 5).
[2]
Figure 15.25 Example of Phase Counting Mode Setting Procedure