AT32F421
Series Reference Manual
2022.11.11
Page 216
Rev 2.02
Figure 14-54 Counting in external clock mode A, with PR=0x32 and DIV=0x0
30
COUNTER
OVFIF
TMR_CLK
110
STIS[2:0]
Clear
CNT_CLK
C2IRAW
000
C2IF[2: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.
The TMR15 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 TMR15_DIV register. The prescaler value can be modified at any
time, but it takes effect only when the next overflow event occurs.
The internal trigger input is configured as follows:
Set the TMRx_PR register to set counting period;
Set the TMRx_DIV register to set counting frequency;
Set the STIS[2:0] bit (range:
3’b000~3’b011) in the TMRx_STCTRL register and select internal
trigger;
Set
SMSEL[2:0]=3’b111 in the TMRx_STCTRL register and select external clock mode A;
Set the TMREN bit in the TMRx_CTRL1 register to enable TMRx counter.
Table 14-9 TMR15 internal trigger connection
Slave timer
IS0 (STIS=000)
IS1 (STIS=001)
IS2 (STIS=010)
IS3 (STIS=011)
TMR15
-
TMR3
TMR16_OC
TMR17_OC
Figure 14-55 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.4.3.2 Counting mode
The TMR15 timer supports several counting modes to meet different application scenarios.
The TMRx_PR register is used to configure the counting period. The value in the TMRx_PR is
immediately moved to the shadow register by default. When the periodic buffer is enabled (PRBEN=1),
the value in the TMRx_PR register is transferred to the shadow register at an overflow event.
The TMRx_DIV register is used to configure the counting frequency. The counter counts once every