References

The reference voltage for the ADC (VREF) controls the conversion range of the ADC. External reference and five internal references are available.

ADC0.CTRLC = ADC_REFSEL_1024MV_gc;  /* Reference selection 1.024V */

Except for VDD, the internal reference voltages are generated from an internal band gap reference. VDD must be at least 0.5V higher than the selected band gap reference voltage.

Changing the reference while a conversion is ongoing will corrupt the output. To safely change input or reference when using Free-Running mode, disable Free-Running mode and wait for the conversion to complete before doing any changes. Enable Free-Running mode before starting the next conversion.

ADC0.CTRLF &= ~ADC_FREERUN_bm;                /* Disable Free-Running */
while(!(ADC0.INTFLAGS & ADC_SAMPRDY_bm));     /* Wait until conversion done */
ADC0.CTRLC = ADC_REFSEL_VDD_gc;               /* Configure VDD as reference */
ADC0.CTRLF |= ADC_FREERUN_bm;                 /* Enable Free-Running */