2 months ago.

STM32_ADC_InternalChannels program does NOT work correctly

Hi everyone (especially ST team members),

I'm trying following program similar as ST sample program.

#include "mbed.h"
AnalogIn adc_temp(ADC_TEMP);
AnalogIn adc_vref(ADC_VREF);
int main(){
    while(1) {
        printf("ADC Temp = %f\r\n",;
        printf("ADC VRef = %f\r\n",;         

On Nucleo-F411RE(mbed Release 148) , I got a following screen shot.

ADC Temp = 0.232723
ADC VRef = 0.238339
ADC Temp = 0.234921
ADC VRef = 0.258608

If I commented out line 6 "printf("ADC Temp = %f\r\n",;", I got follows.

ADC VRef = 0.367277
ADC VRef = 0.313553
ADC VRef = 0.313553
ADC VRef = 0.312821

Data differs between 1st one which is just after start and others.
I refered STM en.DM00115249.pdf and found Vref rang(page 120/149).
VREFINT Internal reference voltage 1.18(min), 1.21(typ), 1.24(max) V

My board Vdd is 3.312V then
0.238339 * 3.312 = 0.7894 V
0.367277 * 3.312 = 1.2164 V
0.313553 * 3.312 = 1.0385 V

It seems that 0.367277 is correct value and others are wrong data.
I observed the same phenomenon on Nucleo-F446RE using same program.

Is there any advice?

Comment on this question

1 Answer

2 months ago.


I made some trials and it seems to be related to the ADC sampling time which is too low. I have increased it to 480 cycles and I measure 0.367 on Vref (with Vtemp enabled too).

I will send a patch on GitHub.

Thanks for reporting.

To post an answer, please log in.