best way to average a few hundred ADC values


Our application acquires some ADC values (32bit, ~ a few hundred points), and we want to compute the average value.

What's the best way to implement so we can avoid rollover and have high accuracy?

BTW, we are using BF518.


  • I presume you are concerned that if you added all the values together then divided by the total number of values, you'd have potential rollover? You could calculate a rolling average with each sample. You could have a 64 bit rolling average value and a second value to store the weight (ie. number of samples currently in the rolling average. Then perform a weighted average with each new sample. When done, convert the rolling average back to 32 bit value.

  • 0
    •  Analog Employees 
    on Aug 13, 2019 9:49 AM


    Are you facing any issue on computing ADC sample's? If yes, could you please elaborate what do you mean rollover, so that we can comment better on this.

    However, we would suggest you look at the POST Example provide in the below installation directory if you are using the VDSP++ software, where the two tests ( adc _test.c and audio_test.c) checking the communication of processor with ADC on the ADSP-BF518F Ezkit. You can refer these code's for how the data has read from ADC and how it has handled to provide a non distorted audio(for audio_test.c).
    (Installation_Directory)\Analog Devices\VisualDSP 5.1.2\Blackfin\Examples\ADSP-BF518F EZ-Board\Power_On_Self_Test

    If you are using the CCES Software for Developing, we would suggest you download the ADSP-BF518F Board Support Package (BSP) from the below link and install it your PC. Once you installed, the Audio loop back and ADC codes are found in the below installation path.
    BSP Link :
    Readme Link:
    (Installation_Directory)\Analog Devices\ADSP-BF518F_EZKIT-Rel1.0.0\BF518F_EZ-Board\Blackfin\Examples

    Anand Selvaraj.