
AT32F413
Series Reference Manual
2022.06.27
Page 227
Rev 2.00
Figure 14-49
Counting in external clock mode B
30
COUNTER
OVFIF
TMR_CLK
00
ESDIV[1:0]
Clear
CNT_CLK
EXT
0000
ESF[3:0]
31
32
0
1
2
3
4
Internal trigger input (ISx)
Timer synchronization allows interconnection between several timers. The TMR_CLK of one timer can
be provided by the TRGOUT signal output by another timer. Set the STIS[2: 0] bit to select internal
trigger signal to enable counting.
Each timer consists of a 16-bit prescaler, which is used to generate the CK_CNT that enables the counter
to count. The frequency division relationship between the CK_CNT and TMR_CLK can be adjusted by
setting the value of the TMRx_DIV register. The prescaler value can be modified at any time, but it takes
effect only when the next overflow event occurs.
Table 14-11
TMRx internal trigger connection
Slave timer
IS0 (STIS=000)
IS1 (STIS=001)
IS2 (STIS=010)
IS3 (STIS=011)
TMR1
TMR5
TMR2
TMR3
TMR4
TMR8
TMR1
TMR2
TMR4
TMR5
Figure 14-50
Counter timing with prescaler value changing from 1 to 4
TMR_CLK
CK_CNT
COUNTER
OVFIF
DIV[15
:
0]
18
17
19
1A
1B
1C
0
3
00
01
Clear
PR[15
:
0]
1C
14.3.3.2 Counting mode
The advanced-control timer consists of a 16-bit counter supporting up, down, up/down counting modes.
The TMRx_PR register is loaded with the counter value. The value in the TMRx_PR is immediately
moved to the shadow register by deault. When the periodic buffer is enabled (PRBEN=1), the value in
the TMRx_PR register is transferred to the shadow register only at an overflow event. The OVFEN and
OVFS bits are used to configure the overflow event.
Settng TMREN=1 to enable the timer to start counting. Base on synchronization logic, however, the
actual enable signal TMR_EN is set 1 clock cycle after the TMREN is set.
Upcounting mode
In upcounting mode, the counter counts from 0 to the value programmed in the TMRx_PR register, then
restarts from 0, and generates a counter overflow event, with the OVFIF bit being set to 1. If the overflow
event is disabled, the counter is no longer reloaded with the preload value and period value at a counter
overflow event, otherwise, the counter is updated with the preload value and period value on an overflow
event.