Skip to main content
deep_rune
Associate III
December 23, 2020
Question

need help understanding Vref / Vdda

  • December 23, 2020
  • 5 replies
  • 12706 views

I'm trying to find what voltage reference my ADC is using, as it is not going up to 0xFFF. Along the line, I have become quite confused about the Vref - I used to use other chips where the Vref is just a reference voltage for the ADC, but with STM32 it seems it's more complicated.

I'm confused by the function of the Vref / Vdda pin on the STM32L412 - is this a power pin, or a voltage reference pin? I looked through the reference manual but the information was ambiguous. If it's a power pin, how much current does it need? And how does the Vref work?

This topic has been closed for replies.

5 replies

TDK
Super User
December 23, 2020

VDDA is a power pin. It must be the same as VDD for most (all?) STM32 chips.

VREF+ is a voltage reference pin.

On smaller packages, these two pins are bonded together, which means VREF+ = VDDA. This means it is both a power pin and a voltage reference pin.

"If you feel a post has answered your question, please click ""Accept as Solution""."
deep_rune
deep_runeAuthor
Associate III
December 23, 2020

ok.. so if my chip runs off 3.3V but I want to run the ADC of a 3v reference, I can only do this on a chip with separate VDDA and Vref+ pins?

TDK
Super User
December 23, 2020
That is correct.
"If you feel a post has answered your question, please click ""Accept as Solution""."
Tesla DeLorean
Guru
December 23, 2020

There is an internal intVRef (1.25V as I recall) that can attach to the ADC and can be used as a calibration point

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
waclawek.jan
Super User
December 24, 2020

My take on the topic.

JW

S.Ma
Principal
August 6, 2022

It should be the bandgap voltage, works like an internal regulator. By measuring it, vdda can be deducted.

waclawek.jan
Super User
August 9, 2022

> in practice I'm getting an error of around 30mV when reading a 1393mV source.

Did you perform ADC calibration before measurement, as outlined in the ADC chapter in RM?

Also, next time, don't hijack an old thread, start your own.

JW

DCarr.1
Associate III
August 9, 2022

I believe so, although I could be doing it wrong:

main.c

int main(void) {
 HAL_Init();
 SystemClock_Config();
 MX_GPIO_Init();
 MX_ADC1_Init();
 
 if (HAL_ADCEx_Calibration_Start(&hadc1, ADC_SINGLE_ENDED) != HAL_OK) {
	 Error_Handler();
 }
 
 while (1) {
		if (HAL_ADC_Start(&hadc1) != HAL_OK) {
		 Error_Handler();
		}
 
		if (HAL_ADC_PollForConversion(&hadc1, 100) != HAL_OK) {
			Error_Handler();
		}
 
	 float adc = (float)HAL_ADC_GetValue(&hadc1);
 
	 float vref = 2500.0f;
	 float vadc = (adc * vref) / 4096.0f;
 
	 float R14 = 47000;
	 float R15 = 100000;
	 float vbat = vadc * (R14 + R15) / R15;
 
	 __NOP();
 }