I have noticed something peculiar. I have removed SB57 to allow using VDDA/REF+ for external analog voltage reference. I have tied A0 directly to VDDA (pin 8, CN5), and to the voltage output from a Siglent SPD1305X power supply. Nucleo GND is tied to the GND of power supply.
In this situation, you'd expect the analogRead(A0) to consistently read 1023 (max value) since the reference voltage and the A0 input are the same. However this is not the case.
See sketch and serial monitor output. Any ideas what might be going wrong here? N.B. I am familiar with STM application note AN2834 on ADC accuracy.
EDIT: The result is the same when SB57 is ON (i.e. connected), and I feed the 3.3 V Nucleo output straight to A0. No external power supply attached.
Sketch
Code: Select all
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
// analogReadResolution(12);
}
void loop() {
// Calculate the voltage of the voltage divider
Serial.println(analogRead(A0));
delay(100);
}
Code: Select all
12:32:16.707 -> 1022
12:32:16.820 -> 1022
12:32:16.908 -> 1022
12:32:17.002 -> 1022
12:32:17.095 -> 1022
12:32:17.221 -> 1022
12:32:17.299 -> 1023
12:32:17.424 -> 1022
12:32:17.516 -> 1022
12:32:17.611 -> 1023
12:32:17.703 -> 1022
12:32:17.797 -> 1022
12:32:17.921 -> 1023
12:32:18.014 -> 1023
12:32:18.107 -> 1022
12:32:18.200 -> 1023
12:32:18.326 -> 1022
12:32:18.418 -> 1023
12:32:18.512 -> 1021
12:32:18.589 -> 1022
12:32:18.713 -> 1022
12:32:18.806 -> 1022
12:32:18.899 -> 1022
12:32:19.016 -> 1022
12:32:19.110 -> 1023
12:32:19.203 -> 1022
12:32:19.295 -> 1022
12:32:19.421 -> 1022
12:32:19.514 -> 1022
12:32:19.606 -> 1022
12:32:19.699 -> 1022
12:32:19.824 -> 1022
12:32:19.917 -> 1023
12:32:20.005 -> 1023
12:32:20.097 -> 1022
12:32:20.223 -> 1022
12:32:20.317 -> 1022
12:32:20.409 -> 1022
12:32:20.504 -> 1022
12:32:20.596 -> 1023
12:32:20.721 -> 1022
12:32:20.815 -> 1023
12:32:20.924 -> 1022
12:32:21.002 -> 1023
12:32:21.125 -> 1023
12:32:21.205 -> 1022
12:32:21.299 -> 1022