39.5.4 Window Operation
The 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 must have the same measurement mode setting in their respective Comparator Control Registers (COMPCTRLx.SINGLE).
- Both comparators must be enabled
(COMPCTRLx.ENABLE =
1
) before the Window mode is enabled (WINCTRL.WEN0 =1
). - Window mode must be first disabled (WINCTRL.WEN0
=
0
) before both comparators are disabled (COMPCTRLx.ENABLE =0
). - Ensure to check the ready bits for both comparators (STATUSB.READYx =
1
) before reading the measurement results.
To physically configure the comparators for Window mode, the user must ensure to choose the same I/O pin as positive input for each comparator, providing a shared input signal. The negative inputs define the range for the window. In the figure below, 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).
When the comparators are configured for Window
mode and Single-shot mode, measurements are performed simultaneously on both comparators.
Writing 1
to either the Start Comparison bit in the Control B register
(CTRLB.STARTx) starts a measurement. Likewise, either peripheral event can start a
measurement. The STATUSA.WSTATE bit field must be read only after STATUSB.READY bits of both
the related comparators are set.