![ARTERY AT32F435 Series Reference Manual Download Page 260](http://html1.mh-extra.com/html/artery/at32f435-series/at32f435-series_reference-manual_2977592260.webp)
AT32F435/437
Series Reference Manual
2022.11.11
Page 260
Rev 2.03
Figure 14-22 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
C1DF
C1IFP1
C2IFP1
STCI
C1C
C1IDIV
input divider
C1EN
C1IRAW
TMRx_CH1
XOR
TMRx_CH2
TMRx_CH3
C1INSEL
Figure 14-173 Channel 1 input stage
Capture
CNT counter
C1DT
C1P/C1CP
edge detector
C1IN
C1IFP1
C2IFP1
STCI
C1C
C1IDIV
input divider
C1IPS
C1IF
XOR
TMRx_CH2
TMRx_CH3
TMRx_CH1
C1INSEL
C1IRAW
filter
C1DF
C1SWTR
C1EN
C2IF
C2IRAW
C2P/C2CP
edge detector
filter
C2DF
IS2
IS1
IS0
C1INC
IS3
STIS
OR
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 to 1. 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, 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 or DMA request by setting the C1IEN bit in the
TMRx_IDEN register or the C1DEN bit in the TMRx_IDEN register
Timer Input XOR function
The 3 timer input pins (TMRx_CH1, TMRx_CH2 and TMRx_CH3) are connected to the channel 1
(selected by setting the C1INSE in the TMRx_CTRL2 register) through an XOR gate.
The XOR gate can be used to connect Hall sensors. For example, connect the three XOR inputs to the
three Hall sensors respectively so as to calculate the position and speed of the rotation by analyzing
three Hall sensor signals.
Input selection
The TMR2 IS1 (internal trigger input 1) and TMR5 channel 4 are mappable through the TMRx_RMP
register. The TMR2 IS1 can be configured as TMR8_TRGO, Ethernet PTP output, OTG1_FS_SOF or
OTG2_FS_SOF. TMR5 channel 4 input can be configured as GPIO, LICK, LEXT or ERTC.