cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L051C8 uses ADC to measure voltage value error is 50mV

*于.1
Associate II

STM32L051C8 uses ADC to measure the voltage value. The measured voltage value of the AD pin is 0.432V,VCC=3.335V, and the voltage value obtained through AD collection is 0.48V; there is an error of 50mV, and the ADC part of the program and hardware are as follows:

0693W000006I984QAC.png0693W000006I99RQAS.png HAL_GPIO_WritePin(GPIOA, GPIO_PIN_11, GPIO_PIN_SET); //¿ªÆôºó²â�?¿9´®µçѹֵ

HAL_Delay(200);

HAL_ADC_Start_DMA(&hadc,(uint32_t *)ADC_ConvertedValue,2); 

  HAL_Delay(100);

VCC1_r =(float)(ADC_ConvertedValue[0])*3.3/4096; // 9´®ºóµÚ1×éµçѹ

VCC2_r =(float)(ADC_ConvertedValue[1])*3.3/4096; // 9´®ºóµÚ2×éµçѹ

6 REPLIES 6
Peter BENSCH
ST Employee

Please read section 13.3.3 of RM0377, which describes the calibration of the ADC.

Please also replace 3.3 in your calculation with the actual value of the voltage at the VDDA, as the ADC references to this voltage and a deviation will add more error.

To get the actual value of VDDA it may be necessary to measure against a reference voltage, either internal or external depending on your requirements.

Good luck!

When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Thanks for the answer, after I use the actual measured VDDA value, there is still a big error.

What does "big error" mean for you?

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

50mV

Peter BENSCH
ST Employee

There are a number of adjustments that can be made to improve accuracy.

A good source for inspiration is AN2834: How to get the best ADC accuracy in STM32 microcontrollers.

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Ozone
Lead

>The measured voltage value of the AD pin is 0.432V,VCC=3.335V, ...

Your schematic shows VDDA is not connected to Vcc, so Vcc does not matter.

The ADC result depends on Vref, which is not necessarily VDDA.

Check the datasheet & reference manual.