AT32F425
Series Reference Manual
2022.03.30
Page 196
Ver 2.01
Input mode
In input mode, the TMRx_CxDT registers latch the current counter values after the selected triggle 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 and CxDEN bits are enabled. If the selected trigger signal is detected when
the CxIF is set, the CxOF is set.
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 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.
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.
Figure 14-20
Capture/compare channel output stage (channel 1 to 4)
Output
mode
controller
CxORAW
Output
enable
circuit
CxOUT
EXT
CVAL>CxDT
CVAL = CxDT
To the master
mode controller
CVAL
CxDT
Compare
Polarity
selection
Output mode
Write CxC[2: 0]≠2’b00 to configure the channel as output to implement multiple output modes. In this
case, the counter value is compared with the value in the TMRx_CxDT register, and the intermediate
signal CxORAW is generated according to the output mode selected by CxOCTRL[2: 0], which is sent
to IO after being processed by the output control circuit. The period of the output signal is configured by
the TMRx_PR register, while the duty cycle by the TMRx_CxDT register.
Output compare modes include:
PWM mode:
Set CxOCTRL=3’b110/111 to enable PWM mode. Each channel can be
independently configured to output one PWM signal. In this case, the period of the output signal
is configured by the TMRx_PR register, and the duty cycle by the CxDT register. The counter
value is compared with the value of the TMRx_CxDT register, and the corresponding level signal
is sent according to the counting direction. For more information on PWM mode A/B, refer to the
description of the CxOCTRL[2: 0] bit. In up/down counting mode, the OWCDIR bit is used to
indicate the counting direction.
Forced output mode:
Set CxOCTRL=3’b100/101 to enable forced output mode. In this case,
the CxORAW is forced to be the programmed level, irrespective of the counter value. Despite
this, the channel flag bit and DMA request still depend on the compare result.