AT32F421
Series Reference Manual
2022.11.11
Page 324
Rev 2.02
19.4 Design tips
The following information can be used for design reference:
Input/Output configuration
As a comparator input, the I/Os must be configured as an analog mode. The comparator output can
be remapped onto external I/Os.
Comparator output configuration:
Multiplexed
GPIOA_MUXL[3:0]=0111 GPIOA_MUXL[27:24]=0111 GPIOA_MUXH[15:12]=0111
Output port
PA0
PA6
PA11
Locking
The CMP_CTRLSTS register can be write-protected. After the completion of programming, the
corresponding bits in the CMP_CTRLSTS register can be read-only by setting CMPWP=1, including
the CMPWP bit. The write protection can be unlocked only after a system reset. This feature can be
used for the applications with specific security requirements.
Low-power mode
The comparator clock enable control register is shared with the SCFG register. The clock source is
PCLK, and uses system reset as its reset signal. The comparator still works in Deepsleep mode,
which can be used as an EXINT interrupt source to wakeup device from low-power mode. However,
prior to Deepsleep mode entry, it is necessary to disable the digital filtering of the comparator (setting
GFE=0 of the G_FILTER_EN register).
19.5 Functional overview
19.5.1 Analog comparator
Positive/Negative input selection
Select an I/O or VSSA as a positive input source through the CMPxNINVSEL[1: 0] bit in the
CMP_CTRLSTS register; Select an internal reference voltage, three voltage divider values or an I/O as
a negative input source through the CMPxINVSEL[2: 0] bit. The SCALEN bit, along with the BRGEN bit,
is used to enable voltage divider values.
Hysteresis
The hysteresis feature can be selected through the CMPxHYST[1: 0] bit in the CMP_CTRLSTS register.
This is used to avoid fake signal caused by noise. Hysteresis can be disabled if not needed.
Operating mode
The controller can operate in high speed/maximum power consumption, medium speed/medium power
consumption, low speed/low power consumption or ultra-low speed/ultra-lower power consumption in
order to achieve the best trade-off between performance and power consumption. The operating mode
is selected through the CMPxSSEL bit in the CMP_CTRLSTS register.
Output blanking
The CMPBLANKING[2: 0] of the CMP_CTRLSTS register is used to select the sources of the comparator
blanking window. This feature can be used to prevent the generation of peak current at the start of the
PVM.