6 Measurements

In Single mode, upon receiving a conversion trigger, a single sampling result is available in the ADC Result (ADCn.RESULT) register and Sample (ADCn.SAMPLE) register. When the result is ready, the RESRDY and SAMPRDY bits in the Interrupt Flags (ADC.INTFLAGS) register are set.

In Single mode, the result in ADCn.RESULT and ADCn.SAMPLE is equal.

The code snippet below shows how to start the ADC conversion, wait until the conversion is done, and read the result from the sample register.

ADC0.COMMAND |= ADC_START_IMMEDIATE_gc; /* Start ADC conversion */
while(!ADC0.INTFLAGS & ADC_SAMPRDY_bm); /* Wait until the conversion is done */ 
adc_result = ADC0.SAMPLE; /* Read sample */

Similarly, the code below shows the same as above, but this time reading the result register.

ADC0.COMMAND |= ADC_START_IMMEDIATE_gc; /* Start ADC conversion */
while(!ADC0.INTFLAGS & ADC_RESRDY_bm); /* Wait until the conversion is done */ 
adc_result = ADC0.RESULT; /* Read result */