6 ADC Window Comparator
In Window Comparator mode, the device can detect if the ADC result is below or above a specific threshold value. This is useful when monitoring a signal that is required to be maintained in a specific range, or for signaling low battery/overcharge, etc. The window comparator can be used in both Free-Running mode and Single Conversion mode. In this example, the window comparator is used in Free-Running mode, because a monitored signal requires continuous sampling, and the Free-Running mode reduces the CPU load by not requiring a manual start for each conversion.
ADC0.WINLT = WINDOW_CMP_LOW_TH_EXAMPLE;
ADC0.CTRLE = ADC_WINCM_BELOW_gc;
1
’ to
it.ADC0.INTFLAGS = ADC_WCMP_bm;
An MCC generated code example for AVR128DA48, with the same functionality as the one described in this section, can be found here: