
EM358x
168
Rev. 0.4
10.3.1.1 Prescaler
The prescaler can divide the counter clock frequency by power of two from 1 through 32768. It is based on a 16-
bit counter controlled through the 4-bit TIM_PSCEXP bit field in the TIMx_PSC register. The factor by which the
counter is divided is two raised to the power TIM_PSCEXP (2
TIM_PSCEXP
).
It can be changed on the fly as this control register is buffered. The new prescaler ratio is used starting at the next
UEV.
Figure 10-2 gives an example of the counter behavior when the prescaler ratio is changed on the fly.
Figure 10-2. Counter Timing Diagram with Prescaler Division Change from 1 to 4
10.3.2 Counter Modes
10.3.2.1 Up-Counting Mode
In up-counting mode, the counter counts from 0 to the auto-reload value (contents of the TIMx_ARR register),
then restarts from 0 and generates a counter overflow event.
A UEV can be generated at each counter overflow, by setting the TIM_UG bit in the TIMx_EGR register, or by
using the slave mode controller.
Software can disable the UEV by setting the TIM_UDIS bit in the TIMx_CR1 register, to avoid updating the
shadow registers while writing new values in the buffer registers. No UEV will occur until the TIM_UDIS bit is
written to 0. Both the counter and the prescaler counter restart from 0, but the prescale rate does not change. In
addition, if the TIM_URS bit in the TIMx_CR1 register is set, setting the TIM_UG bit generates a UEV but without
setting the INT_TIMUIF flag. Thus no interrupt request is sent. This avoids generating both update and capture
interrupts when clearing the counter on the capture event.
When a UEV occurs, the update flag (the INT_TIMUIF bit in the INT_TIMxFLAG register) is set (unless TIM_URS
is 1) and the following registers are updated:
The buffer of the prescaler is reloaded with the buffer value (contents of the TIMx_PSC register).
The auto-reload shadow register is updated with the buffer value (TIMx_ARR).
Summary of Contents for EMBER EM358 series
Page 2: ...EM358x 2 Rev 0 4 ...
Page 7: ...EM358x Rev 0 4 7 ...