www.geehy.com Page 213
When the counter is in count-up mode, the counter will count up from 0; every
time a pulse is generated, the counter will increase by 1 and when the value of
the counter (TMRx_CNT) is equal to the value of the auto reload
(TMRx_AUTORLD), then the counter will start to count again from 0, a count-up
overrun event will be generated, and the value of the auto reload
(TMRx_AUTORLD) is written in advance.
Disable the update event and set UD bit of TMRx_CTRL1 register to 1.
Generate the update interrupt or DMA request and set URSSEL bit in
TMRx_CTRL1 register.
When an update event occurs, both the auto reload register and the prescaler
register will be updated.
Figure 87 Counter Timing Diagram, the internal clock division factor is 1 or 2
CNT_EN
CK_CNT
21
22
23
24
25
26
27
00
01
02
03
04
Counter register
Counter overrun
Update event
CK_PSC
PSC=1
CK_CNT
05
06
0024
0025
0026
0000
0001
0002
0003
Counter overrun
Update event
PSC=2
Counter register
Prescaler PSC
The prescaler is 16 bits and programmable, and it can divide the clock frequency
of the counter to any value between 1 and 65536 (controlled by TMRx_PSC
register), and after frequency division, the clock will drive the counter CNT to
count. The prescaler has a buffer, which can be changed during running.