4 ADC Free-Running
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.
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.
An MCC generated code example for AVR128DA48, with the same functionality as the one described in this section, can be found here: