5.2 Accumulation

The ADC supports sampling in series where a configurable number of conversion results are automatically accumulated into a single ADC result. A maximum of 1024 samples can be accumulated. Sample accumulation is configured by writing the Sample Accumulation Number Select (SAMPNUM) bit field in the Control F (ADCn.CTRLF) register.

The 16-bit Sample (SAMPLE) register will always be updated with the latest ADC conversion output (one sample). The samples are accumulated in an internal sample accumulator which is sufficiently wide to avoid overflow for all supported accumulation configurations. The accumulated result is transferred to the 32-bit Result (ADCn.RESULT) register when the selected number of samples are finished, and the Result Ready (RESRDY) bit in the Interrupt Flags (ADCn.INTFLAGS) register is set.

The code snippet below shows the configuration to accumulate 1024 samples:

ADC0.CTRLF = ADC_SAMPNUM_ACC1024_gc;