R01UH0823EJ0100 Rev.1.00
Page 540 of 1823
Jul 31, 2019
RX23W Group
23. Multi-Function Timer Pulse Unit 2 (MTU2a)
23.3.6
Phase Counting Mode
When phase counting mode is specified, an external clock is selected as the count clock and the TCNT counter operates
as an up-counter/down-counter regardless of the setting of the TCR.TPSC[2:0] bits and TCR.CKEG[1:0] bits. However,
the functions of the TCR.CCLR[2:0] bits and of registers TIOR, TIER, and TGR are valid, and input capture/compare
match and interrupt functions can be used.
This can be used for 2-phase encoder pulse input.
If an overflow occurs while the TCNT counter is counting up, a TCIV interrupt is generated while the corresponding
TIER.TCIEV bit is 1. If an underflow occurs while the TCNT counter is counting down, a TCIU interrupt is generated
while the corresponding TIER.TCIEU bit is 1.
The TSR.TCFD flag is the count direction flag. Read the TCFD flag to check whether the TCNT counter is counting up
or down.
In phase counting mode, the external clock pins MTCLKA, MTCLKB, MTCLKC, and MTCLKD can be used as 2-
phase encoder pulse input pins.
lists the correspondence between external clock pins and channels.
(1) Example of Phase Counting Mode Setting Procedure
shows an example of the phase counting mode setting procedure.
Figure 23.29
Example of Phase Counting Mode Setting Procedure
Table 23.44
Clock Input Pins in Phase Counting Mode
Channel
External Clock Input Pins
A-Phase
B-Phase
MTU1
MTCLKA
MTCLKB
MTU2
MTCLKC
MTCLKD
[1]
[2]
[1] Select phase counting mode with the
TMDR.MD[3:0] bits.
[2] Set the TSTR.CSTn bit to 1 to start the
count operation.
Phase counting mode
Select phase counting
mode
Start count
Phase counting mode