General purpose timer (TIMx) UM0306
246/519
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, IC1FP1 mapped on TI1).
● CC2S=’01’ (TIMx_CCMR2 register, IC2FP2 mapped on TI2).
● CC1P=’0’ (TIMx_CCER register, IC1FP1 non-inverted, IC1FP1=TI1).
● CC2P=’0’ (TIMx_CCER register, IC2FP2 non-inverted, IC2FP2=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 106. Example of counter operation in encoder interface mode.
Figure 107 gives an example of counter behavior when IC1FP1 polarity is inverted (same
configuration as above except CC1P=’1’).
Figure 107. Example of encoder interface mode with IC1FP1 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
capture mode. The output of the encoder which indicates the mechanical zero can be used
for this purpose. Depending on the time between two events, the counter can also be read
TI1
forward forwardbackwardjitter jitter
up
down up
TI2
COUNTER
TI1
forward forwardbackwardjitter jitter
up
down
TI2
COUNTER
down