AT32WB415
Series Reference Manual
2022.04.13
Page 186
Ver 2.00
Figure 14-31 Counting in external clock mode A
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.
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-6 TMRx internal trigger connection
Slave controler
IS0
(STIS=000)
IS1
(STIS = 001)
IS2
(STIS = 010)
IS3
(STIS = 011)
TMR9
TMR2
-
TMR10_OC
TMR11_OC
Note: If there is no corresponding timer in a device, the corresponding trigger signal ISx is not present.
Figure 14-32 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.2.3.2 Counting mode
The general-purpose timer consists of a 16-bit counter supporting upcounting mode. 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,
restarts from 0, and generates a counter overflow event, with the OVFIF bit being set. If the overflow
event is disabled, the register is no longer reloaded with the preload and re-loaded value after counter
overflow occurs, otherwise, the prescaler and re-loaded value will be updated at an overflow event.