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 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;