UM0306 General purpose timer (TIMx)
223/519
The Time Base Unit includes:
● Counter Register (TIMx_CNT)
● Prescaler Register (TIMx_PSC):
● Auto-Reload Register (TIMx_ARR)
The auto-reload register is preloaded. Writing or reading the auto-reload register access the
preload register. The content of the preload register is transferred in the shadow register
permanently or at each update event UEV, depending on the auto-reload preload enable bit
(ARPE) in TIMx_CR1 register. The update event is sent when the counter reaches the
overflow (or underflow when down-counting) and if the UDIS bit equals 0 in the TIMx_CR1
register. It can also be generated by software. The generation of the update event is
described in detail for each configuration.
The counter is clocked by the prescaler output CK_CNT, which is enabled only when the
counter enable bit (CEN) in TIMx_CR1 register is set (refer also to the slave mode controller
description to get more details on counter enabling).
Note that the actual counter enable signal CNT_EN is set 1 clock cycle after CEN.
Prescaler description
The prescaler can divide the counter clock frequency by any factor between 1 and 65536. It
is based on a 16-bit counter controlled through a 16-bit register (in the TIMx_PSC register).
It can be changed on the fly as this control register is buffered. The new prescaler ratio is
taken in account at the next update event.
Figure 73 and Figure 74 give some examples of the counter behavior when the prescaler
ratio is changed on the fly:
Figure 73. Counter timing diagram with prescaler division change from 1 to 2
CK_PSC
00
CNT_EN
TIMER CLOCK = CK_CNT
COUNTER REGISTER
UPDATE EVENT (UEV)
0
F9 FA FB FCF7
PRESCALER CONTROL REGISTER
01
Write a new value in TIMx_PSC
01 02 03
PRESCALER BUFFER
01
PRESCALER COUNTER
0
1 0 1 0 1 0 1
F8