AT32F425
Series Reference Manual
2022.03.30
Page 214
Ver 2.01
14.3.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-38
Capture/compare channel output stage (channel 1 )
Output mode
controller
C1ORAW
Output
enable
circuit
C1OUT
CVAL>C1DT
CVAL=C1DT
CVAL
C1DT
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.
Output compare mode:
Set CxOCTRL=2’b001/010/011 to enable output compare mode. In this
case, when the counter value matches the value of the CxDT register, the CxORAW is forced high,
low or toggling.
One-pulse mode (TMR9/12 only)
:
This is a particular case of PWM mode. Set OCMEN=1 to
enable one-pulse mode. In this mode, the comparison match is performed in the current counting
period. The TMREN bit is cleared as soon as the current counting is completed. Therefore, only one
pulse is output. When configured as in upcounting mode, the configureation must follow the rule:
CVAL<CxDT≤PR; in downcounting mode, CVAL>CxDT is required.
Fast output mode (TMR9/12 only):
Set CxOIEN=1 to enable this mode. If enabled, the
CxORAW signal will not change when the counter value matches the CxDT, but at the beginning of
the current counting period. In other words, the comparison result is advanced, so the comparison
result between the counter value and the TMRx_CxDT register will determine the level of CxORAW in
advance.
gives an example of output compare mode (toggle) with C1DT=0x3. When the counter
value is equal to 0x3, C1OUT toggles.
gives an example of the combination between upcounting mode and PWM mode A. The
output signal behaves when PR=0x32 but CxDT is configured with a different value.
gives an example of the combination between upcounting mode and one-pulse PWM
mode B. The counter only counts only one cycle, and the output signal sents only one pulse.