3.3 ADC Single Conversion

In this use case, the ADC runs in Single Conversion mode. It runs by configuring the EXAMPLE_CODE definition to SINGLE_CONVERSION in main.c as:

#define EXAMPLE_CODE  SINGLE_CONVERSION

The conversion starts after the ‘read_adc_single_conversion()’ function is called. The ‘ADC_0_get_conversion()’ function is then called, in which ADC_COMMAND.STCONV is written to '1'. When the conversion cycle is completed, the ADC data is converted to voltage format which is printed through the USART to the terminal. One can choose to use the terminal like the one already embedded in Data Visualizer in Atmel Studio.

Since the ‘read_adc_single_conversion()’ function is called continuously in the while(1) loop in the ‘main()’ function, a single conversion is manually configured to start after the previous one is completed. This is why one can observe that the calculated voltage is continuously printed to the terminal, same behavior as in the Free-Running mode. The difference is that, in the Free-Running mode, ADC_COMMAND.STCONV is only written to '1' once when the ‘ADC_0_start_conversion()’ function is called before the while(1) loop starts.

Note: The ‘ADC_0_get_conversion(ADC_CHANNEL)’ function, which reads the ADC data, is defined in adc_basics.c. It will be redefined in the adc_windows.c file when the ADC Window Compare mode is used and all related drivers will be updated in the corresponding driver file adc_windows.c instead of adc_basics.c.