Datasheet
The individual comparators can be used independently (normal mode) or paired to form a window
comparison (window mode).
34.6.2 Basic Operation
34.6.2.1 Initialization
Before enabling the AC, the input and output events must be configured in the Event Control register
(EVCTRL). These settings cannot be changed while the AC is enabled.
34.6.2.2 Enabling, Disabling and Resetting
The AC is enabled by writing a '1' to the Enable bit in the Control A register (CTRLA.ENABLE). The AC is
disabled writing a '0' to CTRLA.ENABLE.
The AC is reset by writing a '1' to the Software Reset bit in the Control A register (CTRLA.SWRST). All
registers in the AC will be reset to their initial state, and the AC will be disabled. Refer to CTRLA for
details.
The individual comparators must be also enabled by writing a '1' to the Enable bit in the Comparator x
Control registers (COMPCTRLx.ENABLE). However, when the AC is disabled, this will also disable the
individual comparators, but will not clear their COMPCTRLx.ENABLE bits.
Related Links
34.8.1 CTRLA
34.6.2.3 Comparator Configuration
Each individual comparator must be configured by its respective Comparator Control register
(COMPCTRLx) before that comparator is enabled. These settings cannot be changed while the
comparator is enabled.
• Select the desired measurement mode with COMPCTRLx.SINGLE. See Starting a Comparison for
more details.
• Select the hysteresis with the COMPCTRLx.HYST bit. See Input Hysteresis for more details.
• Select the comparator speed versus power with COMPCTRLx.SPEED. See Propagation Delay vs.
Power Consumption for more details.
• Select the interrupt source with COMPCTRLx.INTSEL.
• Select the positive and negative input sources with the COMPCTRLx.MUXPOS and
COMPCTRLx.MUXNEG bits. See Selecting Comparator Inputs for more details.
• Select the filtering option with COMPCTRLx.FLEN.
• Select standby operation with Run in Standby bit (COMPCTRLx.RUNSTDBY).
The individual comparators are enabled by writing a '1' to the Enable bit in the Comparator x Control
registers (COMPCTRLx.ENABLE). The individual comparators are disabled by writing a '0' to
COMPCTRLx.ENABLE. Writing a '0' to CTRLA.ENABLE will also disable all the comparators, but will not
clear their COMPCTRLx.ENABLE bits.
34.6.2.4 Starting a Comparison
Each comparator channel can be in one of two different measurement modes, determined by the Single
bit in the Comparator x Control register (COMPCTRLx.SINGLE):
• Continuous measurement
• Single-shot
After being enabled, a start-up delay is required before the result of the comparison is ready. This start-up
time is measured automatically to account for environmental changes, such as temperature or voltage
SAM D21 Family
AC – Analog Comparators
© 2018 Microchip Technology Inc.
Datasheet Complete
DS40001882D-page 934