3.2 ADC Free-Running
In this use case, ADC runs in Free-Running mode. It runs by
configuring the EXAMPLE_CODE
definition to
FREE_RUNNING
in main.c
as:
#define EXAMPLE_CODE FREE_RUNNING
The first conversion is started when the initial configuration of the Free-Running mode is executed. When the conversion cycle is completed, the ADC result is read from the ADC0.res register. The formula of how ADC0.res is calculated is described in ADC Conversion Result. The result is then converted to voltage format in the next line of the code, which is a reverse process of calculating ADC0.res. The converted voltage is then printed through the USART to the terminal. One can choose to use the terminal already embedded in Data Visualizer in Atmel Studio or any other external terminal. A new conversion cycle is then started immediately after the previous conversion cycle is completed.
ADC_0_is_conversion_done()
’ function is defined in
adc_basics.c
. One can open the
src/adc_basics.c
file to check it. It will be
redefined in the adc_windows.c
file when the ADC Window
Compare mode is used and all related drivers will be included in the
corresponding driver file.