2017-02-28 10:19 AM
Hi
I am about to use the on board a/d convertor for the STM32L0x processor. I have looked in the user manual of the chip and HAL user manual, where it mentions HAL_ADCEx_Calibration_Start() etc. for calibrating the a/d. But I cant find the actual sequence of commands to use. Also, after the calibration how can I tell what voltage the a/d value 4095 is equal to, so I can calculate the voltage coming in.
Regards
Scott
2017-02-28 04:28 PM
I cant find the actual sequence of commands to use.
See 4.2 Calibration (ADCAL) in RM0 Note, that this calibration is needed to remove an internal offset of the ADC and it should be performed after reset before any ADC conversion. This calibration has nothing to do with determining the reference voltage, see below. An example code given in appendix A.8.1 of RM. I don't Cube.
A dirty but working code including calibration is for example
https://developer.mbed.org/users/wek/code/STM32L0_TempSensor/
, this has been tried with mbed on a L0 DISCO, as discussedhttps://community.st.com/0D50X00009XkYFCSA3
. This is a dirty simple but somehow working code which could be used as a start; and it assumes a precise reference/VDDA, see below.Also, after the calibration how can I tell what voltage the a/d value 4095 is equal to, so I can calculate the voltage coming in.
You simply divide the readout value by the maximum range and multiply by the value of reference voltage.
In most STM32 but the biggest packages, the ADC's reference, VREF+, is tied to AVDD (and VREF- is mandatorily grounded to AVSS even if standalone pin). This means that you either have a precise enough AVDD (or VREF+ in the big pagkages) and then simply use this value in calculating the ADC's input voltage from the readout number; or you determine AVDD value indirectly by measuring an internal voltage reference VREFINT (see 10 Temperature sensor and internal reference voltage, and its sub-chapter Calculating the actual VDDA voltage using the internal reference voltage). In either case, AVDD (VREF+) must be stable enough to achieve reasonable precision of the readouts.
JW
2017-03-02 11:06 AM
Thanks JW