![ARTERY AT32F435 Series Reference Manual Download Page 261](http://html1.mh-extra.com/html/artery/at32f435-series/at32f435-series_reference-manual_2977592261.webp)
AT32F435/437
Series Reference Manual
2022.11.11
Page 261
Rev 2.03
PWM input
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 edge
of channel 1 input signal triggers capture and saves captured values to the C2DT register. The period
and duty of channel 1 input signal can be calculated through C1DT and C2DT respectively.
Figure 14-184
Example of PWM input mode configuration
C1P=0
C1CP=0
edge detector
C1IF
C1IN
C1IFP1(pos)
C2IFP1
STCI
C1C(2'b01)
C1IRAW
filter
C1DF
C1EN
Capture trigger
C1INC
IS3
IS2
IS1
CI2FP2
STIS(3'b101)
Trigger
mode
Hang
mode
Reset
mode
SMSEL(3'b110)
C2P=1
C2CP=0
edge detector
C2IN
C1IFP2(neg)
C2IFP2
STCI
C2EN
Capture trigger
C2C(2'b10)
Capture
Capture
CNT counter
C1DT
C2DT
reset
(CH1 period)
(CH1 high level time)
IS0
Encoder
mode
EXT
Figure 14-195 PWM input mode
A
0
1
2
3
4
5
6
7
8
9
A
0
1
2
COUNTER
C1C
CH1
0x1
reset counter and C1DT capture
C1P
0x0
C2C
0x2
C2P
0x1
STIS
0x5
SMSEL
0x6
0xA
0x4
C1DT
C2DT
0x0
C2DT capture
3
4
5
6
7
8
9
A
0
1
2
14.2.3.4 TMR output function
The TMR output consists of a comparator and an output controller. It is used to program the period, duty
cycle and polarity of the output signal.