![ARTERY AT32F435 Series Reference Manual Download Page 280](http://html1.mh-extra.com/html/artery/at32f435-series/at32f435-series_reference-manual_2977592280.webp)
AT32F435/437
Series Reference Manual
2022.11.11
Page 280
Rev 2.03
setting the STIS[2:0] bit to drive the counter to start counting. The external clock sources include: C1INC
(STIS=3’b100, channel 1 rising edge and falling edge), C1IFP1 (STIS=3’b101, channel 1 signal with
filtering and polarity selection) and C2IFP2 (STIS=3’b110, channel 2 signal with filtering and polarity
selection).
To use external clock mode A, follow the steps below:
-
Set external source TRGIN parameters
If the TMRx_CH1 is used as a source of TRGIN, it is necessary to configure channel 1 input filter
(C1DF[3:0] in TMRx_CM1 register) and channel 1 input polarity (C1P/C1CP in TMRx_CCTRL
register);
If the TMRx_CH2 is used as source of TRGIN, it is necessary to configure channel 1 input filter
(C2DF[3:0] in TMRx_CM1 register) and channel 2 input polarity (C2P/C2CP in TMRx_CCTR
register);
-
Set TRGIN signal source using the STIS[1:0] bit in TMRx_STCTRL register
-
Enable external clock mode A by setting SMSEL=3
’b111 in TMRx_STCTR register
-
Set counting frequency through the DIV[15:0] in TMRx_DIV register
-
Set counting period through the PR[15:0] in TMRx_PR register
-
Enable counter through the TMREN bit in TMRx_CTRL1 register
Figure 14-42 Block diagram of external clock mode A
C1IFP2
C1IFP1
C1INC
ISx
CK_DIV
Trigger select
Slave mode
control
External clock
control
CI1RAW
Filter
Edge
detector
C2IF_Rising
C2IF_Falling
Polarity
selection
Note: The delay between the signal on the input side and the actual clock of the counter is due to the
synchronization circuit.
Figure 14-323 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.
Each timer (TMR9 ~TMR12) 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.