Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years, 4 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.
/teams/ST/code/STM32_ADC_InternalChannels/
#include "mbed.h" AnalogIn adc_temp(ADC_TEMP); AnalogIn adc_vref(ADC_VREF); int main(){ while(1) { printf("ADC Temp = %f\r\n", adc_temp.read()); printf("ADC VRef = %f\r\n", adc_vref.read()); wait(1.0); } }
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", adc_temp.read());", 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?
1 Answer
7 years, 4 months ago.
Hi,
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.