![ARTERY AT32F435 Series Reference Manual Download Page 284](http://html1.mh-extra.com/html/artery/at32f435-series/at32f435-series_reference-manual_2977592284.webp)
AT32F435/437
Series Reference Manual
2022.11.11
Page 284
Rev 2.03
Figure 14-368 Input/output channel 1 main circuit
Capture
CNT counter
C1DT
Compare
C1DT
preload
0
1
C1OBEN
C1DT_shadow
C1OCTRL
Overflow event
C1ORAW
C1EN
1
0
disable
filter
Capture trigger
C1P
polarity select
to GPIO
C1OUT
C1P/C1CP
edge detector
C1IN
TMRx_CH1
C1IRAW
C1DF
C1IFP1
C2IFP1
STCI
C1C
C1IDIV
input divider
C1EN
Figure 14-379
Channel 1 input stage
Capture
CNT counter
C1DT
C1P/C1CP
edge detector
C1IF
C1IN
C1IFP1
C2IFP1
STCI
C1C
C1IDIV
input divider
C1IPS
TMRx_CH1
filter
C1DF
C1SWTR
C1EN
OR
C2P/C2CP
edge detector
C2IF
TMRx_CH2
filter
C2DF
IS2
IS1
IS0
C1INC
IS3
STIS
Input mode
In input mode, the TMRx_CxDT registers latch the current counter values after the selected trigger signal
is detected, and the capture compare interrupt flag bit (CxIF) is set. An interrupt or a DMA request will
be generated if the CxIEN or CxDEN bit is enabled. If the selected trigger signal is detected when the
CxIF is set to 1, a capture overflow event occurs. The TMRx_CxDT register overwrites the recorded
value with the current counter value, and the CxRF is set to 1.
To capture the rising edge of C1IN input, following the configuration procedure mentioned below:
Set C1C=01 in the TMRx_CxDT register to select the C1IN as channel 1 input;
Set the filter bandwidth of C1IN signal (CxDF[3: 0]);
Set the active edge on the C1IN channel by writing C1P=0 (rising edge) in the TMRx_CCTR
Register;
Program the capture frequency division of C1IN signal (C1DIV[1: 0]);
Enable channel 1 input capture (C1EN=1);
If needed, enable the relevant interrupt by setting the C1IEN bit in the TMRx_IDEN register.
PWM input (TMR9/12)
The PWM input mode applies to channel 1 and channel 2. To enable this mode, map the C1IN and C2IN
to the same TMRx_CHx, and configure the CxIFPx of channel 1/2 to trigger slave timer controller reset.
The PWM input mode can be used to measure the period and duty cycle of input signal. The period and
duty cycle of channel 1 can be measured as follows:
Set C
1C=2‘b01 to set C1IN as C1IFP1;
Set C
1P=1’b0 to set C1IFP1 rising edge active;
Set C
2C=2‘b10 to set C2IN as C1IFP2;
Set C
2P=1’b1 to set C1IFP2 falling edge active;
S
et STIS=3’b101 to set C1IFP1 as the slave timer trigger signal;
Set S
MSEL=3‘b110 to set the slave timer in reset mode;
Set C
1EN=1’b1 and C2EN=1’b1 to enable channel 1 and input capture.
In these configurations, the rising edge of channel 1 input signal triggers capture and saves captured
values to the C1DT register, and channel 1 input signal rising edge resets the counter. The falling