
AT32F413
Series Reference Manual
2022.06.27
Page 187
Rev 2.00
Encoder interface mode
To enble the encoder interface mode, write SMSEL[2: 0]= 3’b001/3’b010/3’b011. In this mode, the two
inputs (C1IN/C2IN) are required. Depending on the level on one input, the counter counts up or down
on the edge of the other input. The OWCDIR bit indicates the direction of the counter, as shown in the
table below:
Table 14-3
Couting direction versus encoder signals
Active edge
Level on opposite signal
(C1INFP1 to C2IN, C2INFP2
to C1IN)
C1INFP1 signal
C2INFP2 signal
Rising
Falling
Rising
Falling
Count on C1IN only
High
Down
Up
No count
No count
Low
Up
Down
No count
No count
Count on C2IN only
High
No count
No count
Up
Down
Low
No count
No count
Down
Up
Count on both C1IN and
C2IN
High
Down
Up
Up
Down
Low
Up
Down
Down
Up
Figure 14-12
Example of counter behavior in encoder interface mode (encoder mode C)
20
21
22
23
24
25
26
27
26
25
24
23
22
21
20
1F
COUNTER
0x3
TWCMSEL
[1:0]
CI1RAW
CI2RAW
UP
DOWN
14.1.3.3 TMR input function
Each of TMR2~TMR5 timers has four independent channels, with each channel being configured as
input or output. As input, the channel can be used for the filtering, selection, division and input capture
of the input signals.
Figure 14-13 Input/output channel 1 main circuit
APB bus
MCU peripheral interface
Channel preload register
Channel shadow register
C1DT
Input
mode
IC1PS
C1EN
C1SWTR
TMR1_SWEVT
Capture
Counter
C1OBEN
C1OBEN
OVF
From tim e base unit
TMR1_CM1
Comparator
Input
mode
read_in_progress
capture_transfer
write_in_progress
capture_transfer
Output compare
mode
Capture/compare
seletion
C1DT
CVAL=C1DT
CVAL>CIDT
Capture/compare
seletion