cancel
Showing results for 
Search instead for 
Did you mean: 

Calibrating A/D on STM32L0

Scott Dev
Senior
Posted on March 29, 2017 at 21:16

Hi

   Ive been looking through documentation (and web sites), and testing some code on using the A/D on the STM32L0 processor. As the chip I am using uses the VDD as the reference voltage I am currently calculating the Vdd using the following:

VDD= 3V * VrefintCalValue / AdcValue . I got  3.48V. 

I now have been looking the calibration command :

HAL_ADCEx_Calibration_Start(..);

HAL_ADCEx_Calibration_GetValue(..);

HAL_ADCEx_Calibration_SetValue(..);

My question is after calling HAL_ADCEx_Calibration_Start(..); what do I do to get the VDD (above) value?

Do I use the HAL_ADCEx_Calibration_GetValue(..);, and the HAL_ADCEx_Calibration_SetValue(..);?

After I use the calibration commands how does this effect the value in VrefintCalValue to calculate VDD?

And how do I use the calibration value on the A/D value read from a channel?

Sorry for all the questions, but just trying to get my head around how to use the calibration result.

Thanks

Scott

2 REPLIES 2
Posted on March 30, 2017 at 01:04

I don't Cube so I don't know what are those functions to do, but I suspect they are related to the hardware calibration as outlined in 14.4.2  Calibration (ADCAL) in RM0367. You are supposed to do this once after you power up the ADC (and perhaps repeat it when temperature or supply voltage changes significantly).

The latter two functions would then just read and write ADC_CALFACT, which is normally not needed at all.

This has nothing to do with the value you used in the calculation, an ADC readout of the internal voltage reference VREFINT for 3.0V VREF/power supply taken in the factory and then stored in system ROM, which is called,  confusingly, VREFINT_CAL or VREFINT calibration value (the VREF pin and VREFINT voltage source are confusingly similarly named too).

JW

Posted on March 30, 2017 at 11:50

Hi JW

  Thanks for the info. I think I was looking too much into this, and just simply need to call the function, which worked great.  Thanks for the reference to RM0367, that explained it. There is that much good info out there, just not great finding it.

Thanks

Scott