![ARTERY AT32F435 Series Скачать руководство пользователя страница 301](http://html1.mh-extra.com/html/artery/at32f435-series/at32f435-series_reference-manual_2977592301.webp)
AT32F435/437
Series Reference Manual
2022.11.11
Page 301
Rev 2.03
Figure 14-4 Count clock
0
1
External clock mode B
(ECMBEN=1)
TMRx_EXT
ESF
filter
0
1
External clock mode A
(SMSEL=3'b111)
TRGIN
STIS[1:0]
IS0
IS3
IS2
IS1
STIS[1:0]
EXT
C1INC
C1IFP1
C2IPF2
0
1
STIS[2]
External trigger
Internal trigger
0
1
Encoder mode
(SMSEL=3'b001/010/011)
CI1FP1/CI2FP2
CK_INT(form CRM)
DIV_counter
CK_CNT
CNT_counter
ESP
ESDIV
polarity edge
detector
prescaler
Internal clock (CK_INT)
By default, the CK_INT divided by the prescaler is used to drive the counter to start counting. The
configuration process is as follows:
-
Configure the CLKDIV[1:0] bit in the TMRx_CTRL1 register and set CK_INT frequency.
-
Configure the TWCMSEL[1:0] bit in the TMRx_CTRL1 register and select count mode. If the one-
way count direction is set, configure OWCDIR bit in the TMRx_CTRL1 register to select the specific
direction.
-
Configure the TMRx_DIV register and set counting frequency.
-
Configure the TMRx_PR register and set counting period.
-
Configure the TMREN bit in the TMRx_CTRL1 register and enable the counter.
Figure 14-61 Use CK_INT to drive counter, with TMRx_DIV=0x0 and TMRx_PR=0x16
CK_INT
TMREN
COUNTER
12
11
13
14
15
16
00
01
02
03
04
05
06
07
overflow
OVFIF
External clock (TRGIN/EXT)
The counter clock can be provided by two external clock sources, namely, TRGIN and EXT signals.
SMSEL=3’b111
: External clock mode A is selected. Select an external clock source TRGIN signal by
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), C2IFP2 (STIS=3’b110, channel 2 signal with filtering and polarity
selection) and EXT (STIS=3’b111, external input signal with polarity selection, frequency division and
filtering).
ECMBEN=1
:
External clock mode B is selected. The counter is driven by external input that has
gonethrough polarity selection, frequency division and filtering. The external clock mode B is equivalent
to the external clock mode A which selects EXT signal as an external force TRGIN.
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);