Arm Mbed OS support forum

Noise of analog input reading

I noticed that reading the analog inputs of a NUCLEO-F446RE returns a lot of noise:
These analog inputs have a resolution of 12 bits.
I connected one input to ground, another to a voltage source and I take measurements every 15us.
The following remarks are valid for both inputs.

  • I noticed a 10 LSB (Least Significant Bit) offset, so why not. :slightly_smiling_face:
  • I noticed a noise of + or - 2 LSB on a few tens of successive measurements, which brings the measurement precision to 1000 LSB (= approximately 10 bits), it is a little less nice. :neutral_face:
  • I have noticed that peaks which reach + or - 10LSB appear randomly, generally spaced a few tens of measurements apart, which brings the measurement precision to 200 LSB (<8 bits),
    that’s much more annoying. :slightly_frowning_face:

Here is the read program used with MBED-OS 6.2:

#include “mbed.h”

#define WAIT_TIME_MS 500
#define Imax 1000

BufferedSerial port_USB(USBTX,USBRX); // tx, rx

//DigitalOut led1(LED1);
DigitalOut led1(PB_2);
AnalogIn PosVerin(PC_4);
AnalogIn MasseVerin(PA_7);

Timer MyTimer;

char TabChar [300];
int indice;
long TempsMesure[Imax];
double MesurePosVerin[Imax];
double MesureMasse[Imax];

int main()
port_USB.set_baud(115200);//vitesse de transmission 9600; 19200; 38400; 57600; 115200; 230400; 460800; 921600 bauds
for (indice=0; indice<Imax; indice++)
TempsMesure[indice] = MyTimer.elapsed_time().count(); //Temps en us
MesurePosVerin[indice] =;
MesureMasse[indice] =;
sprintf(TabChar, "\nTemps ");
sprintf(TabChar, "%sPosVerin ", TabChar);
sprintf(TabChar, "%sMasse ", TabChar);
sprintf(TabChar, “%s\n”, TabChar);

for (indice=0; indice<Imax; indice++)
sprintf(TabChar, "%ld ",TempsMesure[indice]);
sprintf(TabChar, "%s%ld ", TabChar, (long)(MesurePosVerin[indice]*1E9));
sprintf(TabChar, "%s%ld ", TabChar, (long)(MesureMasse[indice]*1E9));
sprintf(TabChar, “%s\n”, TabChar);
sprintf(TabChar, “\n\n”);

while (true)
led1 = !led1;

Do you have any idea how the read () statement works? Or the origin of the problem?
I know that to correctly read an analog to digital converter you need to use a sample and hold (which can be integrated into the component). This could be related to the problem, it is a hypothesis. :thinking:
Do you know of any other way to read an analog input?


A 10nF capacitor between ground and the analog input is very helpfull.
Also use AVDD as voltage source.