When configuring the ADC in Free Running mode, the next conversion starts
immediately after the previous one completes. To activate this mode, the FREERUN bit in
the ADC0.CTRLA must be set in addition to the normal ADC initialization.
Figure 1. ADC0.CTRLA - set FREERUN
bit
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:
while(1)
{
if (ADC0_conersionDone())
{
adcVal = ADC0_read();
}
}
Tip: The full code example is also
available in the
Appendix section.