5.1 Initialize the ADC

This subsection presents how to initialize the ADC module to run in the Free-Running Conversion mode. This application uses the Config A setup explained in Hardware Configuration. The FREERUN bit in ADC0.CTRLA must be set to activate this mode, in addition to the normal ADC initialization. When configuring the ADC in Free-Running mode, the next conversion starts immediately after the previous one.

Figure 5-1. ADC0.CTRLA - Set the FREERUN Bit

This translates into the following code:

ADC0.CTRLA |= ADC_FREERUN_bm;

The ADC conversion is started by setting the STCONV bit in the ADC0.COMMAND register:

ADC0.COMMAND = ADC_STCONV_bm;

Then, the ADC results can be read in a while loop.