R01UH0823EJ0100 Rev.1.00
Page 706 of 1823
Jul 31, 2019
RX23W Group
25. 16-Bit Timer Pulse Unit (TPUa)
25.3.6.1
Phase Counting Mode Application Example
shows an example in which phase counting mode is set for TPU4, and TPU4 is coupled with TPU3 to
input servo motor 2-phase encoder pulses in order to detect the position or speed.
TPU4 is set to phase counting mode 1, and the encoder pulse A-phase and B-phase are input to the TCLKA and TCLKB
pins.
TPU3 operates with TPU3.TCNT clearing by TPU3.TGRC compare match; TPU3.TGRA and TPU3.TGRC are used for
the compare match function and are set with the speed control cycle and position control cycle. TPU3.TGRB is used for
input capture, with TPU3.TGRB and TPU3.TGRD operating in buffer mode. The TPU4 count clock is specified as the
TPU3.TGRB input capture source, and the pulse width of 2-phase encoder 4-multiplication pulses is detected.
TPU4.TGRA and TPU4.TGRB for TPU4 are specified for input capture, TPU3.TGRA and TPU3.TGRC compare
matches are selected as the input capture source, and the up-/down-counter values for the control cycles are stored.
This procedure enables accurate position/speed detection to be achieved.
Figure 25.29
Phase Counting Mode Application Example
Edge
detection
circuit
TPU4.TCNT
TPU3.TCNT
TPU4.TGRA
(speed cycle capture)
TPU4.TGRB
(position cycle capture)
TPU3.TGRC
(position control cycle)
TPU3.TGRB
(pulse width capture)
TPU3.TGRD
(buffer operation)
TPU3.TGRA
(speed control cycle)
TCLKA
TCLKB
TPU4
TPU3
Count clock
Counter clear
Compare
match
Compare
match
Input capture
Input capture
Input capture