2.2.6 Averaging

The ADC can be configured to trade conversion speed for accuracy by averaging multiple samples in hardware. This feature is suitable when operating in noisy conditions.

You can specify any number of samples to accumulate (up to 1024) and the divide ratio to use (up to divide by 128). To modify these settings the ADC_RESOLUTION_CUSTOM needs to be set as the resolution. When this is set the number of samples to accumulate and the division ratio can be set by the configuration struct members adc_config::accumulate_samples and adc_config::divide_result. When using this mode the ADC result register will be set to be 16-bit wide to accommodate the larger result sizes produced by the accumulator.

The effective ADC conversion rate will be reduced by a factor of the number of accumulated samples; however, the effective resolution will be increased according to Table 2-2.

Table 2-2. Effective ADC Resolution From Various Hardware Averaging Modes

Number of samples

Final result

1

12-bit

2

13-bit

4

14-bit

8

15-bit

16

16-bit

32

16-bit

64

16-bit

128

16-bit

256

16-bit

512

16-bit

1024

16-bit