cancel
Showing results for 
Search instead for 
Did you mean: 

How to know/measure precisely the voltage used by the adc to provide his values.

JParl
Associate

I am currenctly working on STM32L052K6T6. 

I would like to know if there is an appropriate way to measure precisely the voltage used by the adc. 

I read through the documentation that this voltage was on adc_channel17 but i have no idea of to get it. 

I also read there was a calibration Variable called VREFINT_CAL but again i did'nt see the process to use it properly.

I know this voltage is for me aroun 1.8V. But i need to know it untill 1.80000 at least to calculate accurate values of my sensor. Here is attached to this all the data i found untill now that could be useful. And the MCU is powered by a battery with a voltage of 3.7V<V<4.2V.

This discussion is locked. Please start a new topic to ask your question.
3 REPLIES 3
Jan Waclawek
Senior II

Generally, after performing everything needed to start a conversion (including ADC calibration), you

  • enable the VREF by setting ADC_CCR.VREFEN
  • select channel 17 in ADC_CHSELR, a and start conversion
  • perform an ADC conversion
  • from the conversion result, and the factory-stored value (which was measured at VDDA=3.0V), calculate your actual VDDA - you don't need to know the actual VREFINT voltage for this, the formula is V DDA = 3 V x VREFINT_CAL / VREFINT_DATA (see Calculating the actual V DDA voltage using the internal reference voltage in the ADC chapter in RM)
  • use this VDDAvalue to calculate the real voltage from subsequent ADC conversions on external pins - this is described in the subchapter following the abovementioned one in RM

> MCU is powered by a battery with a voltage of 3.7V<V<4.2V

This violates the operating conditions (maximum VDD and VDDA is 3.6V), and at the upper range, even the absolute maximums (which is 4.0V). Don't be surprised if your mcu fails.

JW

JParl
Associate

Thank you for your answer.

I did what you adviced me and i had:

  • 1667 for VREFINT_CAL
  • 2846 for VREFINT_DATA with ADC set on channel17 using 12 bits.

This gave me VDDA = 1.75720...

This is close to 1.8V but i don't think it is the correct voltage.

Indeed, i tried to configure the adc on channel 1 and put a voltage generator at 1.8004V ( Value measured with an oscilloscope) on the ADC. And the ADC (configured on 16 bits) gave me 65520 close to the maximum. So it means that the voltage that the ADC is using must be close to 1.8V, even a bit higher i think and not 1.75720V.

Btw the MCU is not powered with 3.7V there is a voltage adaptation after battery, i got confused on my writting.

raptorhal2
Lead

If you haven't done so yet, I recommend you read Section 14.9 in the STM32L0x2 Reference Manual to understand the difference between VDDA and VREFINT.

It might also be useful to read the STM32L052 Data Sheet on ADC accuracy. While 256 oversamples will reduce noise, the accuracy is still approximately 12 bits.

Cheers, Hal