General-purpose timers (TIM2/TIM3/TIM4/TIM5) RM0440
1292/2126 RM0440 Rev 4
Slave mode selection preload for run-time encoder mode update
It may be necessary to switch from one encoder mode to another during run-time. This is
typically done at high-speed to decrease the Update interrupt rate, by switching from x4 to
x2 to x1 mode, as show on the Figure 427 below.
For this purpose, the SMS[3:0] bit can be preloaded. This is enabled by setting the SMSPE
enable bit in the TIMx_SMCR register. The trigger for the transfer from SMS[3:0] preload to
active value can be selected with the SMSPS bit in the TIMx_SMCR register.
• SMSPS = 0: the transfer is triggered by the update event (UEV) occurring when the
counter overflows when upcounting, and underflows when downcounting. This mode
must be used only when index is disabled (bit IE = 0).
• SMSPS = 1: the transfer is triggered by the Index event.
Figure 427. Encoder mode change with preload transferred on update (SMSPS = 0)
Encoder clock output
The encoder mode operating principle is not perfectly suited for high-resolution velocity
measurements, at low speed, as it will require a relatively long integration time to have a
sufficient number of clock edges and a precise measurement.
At low speed, a better solution is to do an edge-to-edge clock period measurement. This
can be achieved using a slave timer. The timer can output the encoder clock information on
the tim_trgo output. The slave timer can then perform a period measurement and provide
velocity information for each and every encoder clock edge.
This mode is enabled by setting the MMS[3:0] bitfield to 1000, in the TIMx_CR2 register.It is
valid for the following SMS[3:0] values: 0001, 0010, 0011, 1010, 1011, 1100, 1101, 1110,
1111. Any other SMS[3:0] code is not allowed and may lead to unexpected behavior.
29.4.19 Direction bit output
Its is possible to output a direction signal out of the timer, on the tim_oc3 and tim_oc4 output
signals (copy of the DIR bit in the TIMx_CR1 register). This is achieved by setting the
OC3M[3:0] or the OC4M[3:0] bit field to 1011 in the TIMx_CCMR2 register.
MSv45781V1
SMS = 1110SMS = 0001Preload value
Active value
Update event
x4 mode x2 mode x1 mode
SMS = 0011
SMS = 0001SMS = 0011 SMS = 1110