Atmel Xplained Pro Evaluation Kit for the ATSAMD21J18A Microcontroller ATSAMD21-XPRO ATSAMD21-XPRO Data Sheet
Product codes
ATSAMD21-XPRO
877
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181C–SAM-D21_Datasheet–07/2014
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
measurement is compared with the result of the previous measurement (one sampling period earlier). An example of
single-shot operation is shown in
Figure 33-3. Single-Shot Example
For low-power operation, event-triggered measurements can be performed during sleep modes. When the event occurs,
the Power Manager will start GCLK_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
GCLK_AC_DIG are then disabled again automatically, unless configured to wake up the system from sleep.
the Power Manager will start GCLK_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
GCLK_AC_DIG are then disabled again automatically, unless configured to wake up the system from sleep.
33.6.3 Selecting Comparator Inputs
Each comparator has one positive and one negative input. The positive input is fed from an external input pin (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:
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:
z
The positive input is selected by the Positive Input MUX Select bit group in the Comparator Control register
(COMPCTRLx.MUXPOS)
(COMPCTRLx.MUXPOS)
z
The negative input is selected by the Negative Input MUX Select bit group in the Comparator Control
register (COMPCTRLx.MUXNEG)
register (COMPCTRLx.MUXNEG)
In the case of using an external I/O pin, the selected pin must be configured for analog usage in the PORT Controller by
disabling the digital input and output. The switching of the analog input multiplexors is controlled to minimize crosstalk
between the channels. The input selection must be changed only while the individual comparator is disabled.
disabling the digital input and output. The switching of the analog input multiplexors is controlled to minimize crosstalk
between the channels. The input selection must be changed only while the individual comparator is disabled.
33.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. Window mode is enabled by
the Window Enable x bit in the Window Control register (WINCTRL.WENx). Both comparators in a pair must have the
same measurement mode setting in their respective Comparator Control Registers (COMPCTRLx.SINGLE).
the comparators give information about whether an input signal is within this range or not. Window mode is enabled by
the Window Enable x bit in the Window Control register (WINCTRL.WENx). Both comparators in a pair must have the
same measurement mode setting in their respective Comparator Control Registers (COMPCTRLx.SINGLE).
To physically configure the pair of comparators for window mode, the same I/O pin should be chosen for each
comparator’s positive input to create the shared input signal. The negative inputs define the range for the window. In
comparator’s positive input to create the shared input signal. The negative inputs define the range for the window. In
, COMP0 defines the upper limit and COMP1 defines the lower limit of the window, as shown but the window
will also work in the opposite configuration with COMP0 lower and COMP1 higher. The current state of the window
function is available in the Window x State bit group of the Status register (STATUS.WSTATEx).
function is available in the Window x State bit group of the Status register (STATUS.WSTATEx).
Window mode can be configured to generate interrupts when the input voltage changes to below the window, when the
input voltage changes to above the window, when the input voltage changes into the window or when the input voltage
changes outside the window. The interrupt selections are set by the Window Interrupt Selection bit group in the Window
Control register (WINCTRL.WINTSELx[1:0]). Events are generated using the inside/outside state of the window,
regardless of whether the interrupt is enabled or not. Note that the individual comparator outputs, interrupts and events
continue to function normally during window mode.
input voltage changes to above the window, when the input voltage changes into the window or when the input voltage
changes outside the window. The interrupt selections are set by the Window Interrupt Selection bit group in the Window
Control register (WINCTRL.WINTSELx[1:0]). Events are generated using the inside/outside state of the window,
regardless of whether the interrupt is enabled or not. Note that the individual comparator outputs, interrupts and events
continue to function normally during window mode.
When the comparators are configured for window mode and single-shot mode, measurements are performed
simultaneously on both comparators. Writing a one to either Start Comparison bit in the Control B register
(CTRLB.STARTx) starts a measurement. Likewise either peripheral event can start a measurement.
simultaneously on both comparators. Writing a one to either Start Comparison bit in the Control B register
(CTRLB.STARTx) starts a measurement. Likewise either peripheral event can start a measurement.
GCLK_AC
STATUSB.READYx
Sampled
Comparator Output
CTRLB.STARTx
t
STARTUP
Write ‘1’
t
STARTUP
Write ‘1’
2-3 cycles
2-3 cycles