2

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 on how 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 around 1.8V. But i need to know it untill 1.80000 at least to calculate accurate values of my sensor.

To program my MUC i am using Atollic, i did the basic pins configuration using STM32CubeMX.

Isymap_prog
  • 147
  • 4
  • 14
  • 1
    Did you mean to post on [electronics.se]? This doesn't sound programming related at all. – Filburt Jun 07 '19 at 11:22
  • 1
    I'm voting to close this question as off-topic because it should be posted on [electronics.se] – Filburt Jun 07 '19 at 11:23
  • I am programming my MCU with Atollic and i think there is a way to get this voltage by a numeric way. I just need some help to find how. – Isymap_prog Jun 07 '19 at 11:34
  • @Isymap_prog: What drivers / libraries are you using (e.g. HAL, LL, CMSIS)? Are you using STM32CubeMX for code generation? – David Collins Jun 07 '19 at 11:37
  • I am using HAL library and i used STM32CubeMX to do the basic configuration of GPIOs. I also had the idea to use STM32CubeMX to put PB0 as VREF_OUT pin but it does'nt seem to produce any voltage. – Isymap_prog Jun 07 '19 at 11:39

2 Answers2

4

The internal reference voltage is not used by the ADC. It is only used to measure the actual Vref voltage. Vref voltage depending on the version of the chip can be Vref+ or Vdda.

How to measure the actual Vref?

You need to measure the Vrefint (which is about 1.2V) and then using the simple math calcultate the Vref

Vrefint = Vref * (RAW_ADC / 4096)

So Vref = Vrefint * 4096 / RAW_ADC

or if you want to use VREFINT_CAL : Vref = 3 V * VREFINT_CAL / RAD_ADC

0___________
  • 60,014
  • 4
  • 34
  • 74
  • 1
    Thank you for your answer , indeed i am not interessed by this but the voltage used by the ADC to perform his measurements and give his values. Using VREFINT_CAL i found Vref = 1.757V. ( VREFINT_CAL=1667, RAD_ADC=2846) Which is close to 1.8V but not close enough. So i am not sure it is the correct way to know the voltage used by ADC. – Isymap_prog Jun 07 '19 at 12:54
1

You have to do a calibration before measuring good value of channel VREF_INT.

HAL_ADCEx_Calibration_Start(&hadc, ADC_SINGLE_ENDED);
Plutian
  • 2,276
  • 3
  • 14
  • 23
yoann
  • 11
  • 1