Datasheet
To remove the need for polling, an additional means of starting the comparison is also available. A read of
the Status C register (STATUSC) will start a comparison on all comparators currently configured for
single-shot operation. The read will stall the bus until all enabled comparators are ready. If a comparator
is already busy with a comparison, the read will stall until the current comparison is compete, and a new
comparison will not be started.
A single-shot measurement can also be triggered by the Event System. Setting the Comparator x Event
Input bit in the Event Control Register (EVCTRL.COMPEIx) enables triggering on incoming peripheral
events. Each comparator can be triggered independently by separate events. Event-triggered operation is
similar to user-triggered operation; the difference is that a peripheral event from another hardware module
causes the hardware to automatically start the comparison and clear STATUSB.READYx.
To detect an edge of the comparator output in single-shot operation for the purpose of interrupts, the
result of the current measurement is compared with the result of the previous measurement (one
sampling period earlier). An example of single-shot operation is shown in the figure below.
Figure 34-4. Single-Shot Example
GCLK_AC
STATUSB.READYx
Sampled
Comparator Output
CTRLB.STARTx
t
STARTUP
Write ‘1’
t
STARTUP
Write ‘1’
2-3 cycles 2-3 cycles
For low-power operation, event-triggered measurements can be performed during sleep modes. When
the event occurs, the Power Manager will start CLK_AC_DIG. The comparator is enabled, and after the
startup time has passed, a comparison is done and appropriate peripheral events and interrupts are also
generated. The comparator and CLK_AC_DIG are then disabled again automatically, unless configured
to wake up the system from sleep.
Related Links
37. Electrical Characteristics
34.6.3 Selecting Comparator Inputs
Each comparator has one positive and one negative input. The positive input is one of the external input
pins (AINx). The negative input can be fed either from an external input pin (AINx) or from one of the
several internal reference voltage sources common to all comparators. The user selects the input source
as follows:
• The positive input is selected by the Positive Input MUX Select bit group in the Comparator Control
register (COMPCTRLx.MUXPOS)
• The negative input is selected by the Negative Input MUX Select bit group in the Comparator
Control register (COMPCTRLx.MUXNEG)
In the case of using an external I/O pin, the selected pin must be configured for analog use in the PORT
Controller by disabling the digital input and output. The switching of the analog input multiplexers is
controlled to minimize crosstalk between the channels. The input selection must be changed only while
the individual comparator is disabled.
Note: For internal use of the comparison results by the CCL, this bit must be 0x1 or 0x2.
34.6.4 Window Operation
Each comparator pair can be configured to work together in window mode. In this mode, a voltage range
is defined, and the comparators give information about whether an input signal is within this range or not.
SAM D21 Family
AC – Analog Comparators
© 2018 Microchip Technology Inc.
Datasheet Complete
DS40001882D-page 936