3.4 ADC Window Compare
In this use case, ADC runs in Window Compare mode. The ADC can raise
a flag (ADC_INTFLAG.WCOMP) and request an interrupt (WCOMP) when the result
of a conversion is above and/or below certain thresholds. There are four
threshold mode options:
- The result is under a threshold
- The result is over a threshold
- The result is inside a window
- The result is outside a window
In this use case, the result below window option is chosen. This use
case runs by configuring the
EXAMPLE_CODE
definition to
WINDOW_COMPARATOR_MODE
in main.c
as:#define EXAMPLE_CODE WINDOW_COMPARATOR_MODE
The ADC is set in Free-Running mode. LED0 is turned ON when the
function ‘ADC_0_get_window_result()
’ returns true, meaning
the ADC result is under the window threshold value and the Interrupt Flag
bit of the Windows Compare mode is set. Otherwise, LED0 is kept OFF. The
calculated voltage is then printed through the USART to the terminal when a
conversion is completed.