RM0090 General-purpose timers (TIM2 to TIM5)
Doc ID 018909 Rev 4 448/1422
selected. This might occur if the sensor is positioned near to one of the switching points. For
this example we assume that the configuration is the following:
● CC1S= ‘01’ (TIMx_CCMR1 register, TI1FP1 mapped on TI1)
● CC2S= ‘01’ (TIMx_CCMR2 register, TI2FP2 mapped on TI2)
● CC1P= ‘0’, CC1NP = ‘0’, IC1F =’0000’ (TIMx_CCER register, TI1FP1 noninverted,
TI1FP1=TI1)
● CC2P= ‘0’, CC2NP = ‘0’, IC2F =’0000’ (TIMx_CCER register, TI2FP2 noninverted,
TI2FP2=TI2)
● SMS= ‘011’ (TIMx_SMCR register, both inputs are active on both rising and falling
edges)
● CEN = 1 (TIMx_CR1 register, Counter is enabled)
Figure 153. Example of counter operation in encoder interface mode
Figure 154 gives an example of counter behavior when TI1FP1 polarity is inverted (same
configuration as above except CC1P=1).
Figure 154. Example of encoder interface mode with TI1FP1 polarity inverted
The timer, when configured in Encoder Interface mode provides information on the sensor’s
current position. You can obtain dynamic information (speed, acceleration, deceleration) by
measuring the period between two encoder events using a second timer configured in
TI1
forward forwardbackwardjitter jitter
up
down up
TI2
Counter
TI1
forward forwardbackwardjitter jitter
up
down
TI2
Counter
down