R01UH0823EJ0100 Rev.1.00
Page 545 of 1823
Jul 31, 2019
RX23W Group
23. Multi-Function Timer Pulse Unit 2 (MTU2a)
(3) Phase Counting Mode Application Example
shows an example in which MTU1 is in phase counting mode, and MTU1 is coupled with MTU0 to input
2-phase encoder pulses of a servo motor in order to detect position or speed.
MTU1 is set to phase counting mode 1, and the encoder pulse A-phase and B-phase are input to MTCLKA and
MTCLKB.
MTU0.TGRC compare match is specified as the MTU0.TCNT clearing source and registers MTU0.TGRA and
MTU0.TGRC are used for the compare match function and are set with the speed control cycle and position control
cycle. The MTU0.TGRB register is used for input capture, with registers MTU0.TGRB and MTU0.TGRD operating in
buffer mode. The MTU1 count clock is designated as the MTU0.TGRB input capture source, and the widths of 2-phase
encoder 4-multiplication pulses are detected.
Registers MTU1.TGRA and MTU1.TGRB are designated for the input capture function and the MTU0.TGRA and
MTU0.TGRC compare matches are selected as the input capture sources to store the up-counter/down-counter values for
the control cycles.
This procedure enables the accurate detection of position and speed.
Figure 23.34
Phase Counting Mode Application Example
MTCLKA
MTCLKB
MTU1
Edge
detection
circuit
MTU1.TCNT
MTU1.TGRA
(Speed cycle capture)
MTU1.TGRB
(Position cycle capture)
MTU0.TCNT
MTU0.TGRA
(Speed control cycle)
MTU0.TGRC
(Position control cycle)
MTU0
MTU0.TGRB
(Pulse width capture)
MTU0.TGRD
(Buffer operation)