cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L476 measured VREFINT has wrong value

thomasflatz
Associate

Hello all,

I followed the reference manual to determine VDDA for STM32L476VET6, using the VREFINT measured value together with the calibration value using following code:

if (HAL_ADC_PollForConversion(&hadc1,100) == HAL_OK)

{

ADC_measure_VREF = HAL_ADC_GetValue(&hadc1);

ADC_cal_value = (*VREFINT_CAL_ADDR);

VREF_VOLTAGE = 3000*ADC_cal_value/ADC_measure_VREF;

sprintf(str1,"VREF_CAL: %u\r\n",(unsigned int)ADC_cal_value);

sprintf(str2,"VREF_MEAS: %u\r\n",(unsigned int)ADC_measure_VREF);

sprintf(str3,"VDDA: %umV\r\n",(unsigned int)VREF_VOLTAGE);

HAL_UART_Transmit(&huart2, (uint8_t *)str1, 16, 100);

HAL_UART_Transmit(&huart2, (uint8_t *)str2, 17, 100);

HAL_UART_Transmit(&huart2, (uint8_t *)str3, 16, 100);

}

As result I get 3425mV - which is impossible...

VREFINT_CAL is 1658, that seems right. VREFINT_DATA (measured ADC value) is 1425. This value also doesn't change with time.

ADC clock is 32Mhz, Asynchronous clock mode with Prescaler 128 and I use 640.5 cycles conversion time. VDDA is connected to VDD 3.3V via ferrite bead, VDDA and Vref+ are connected via 47ohms resistor (in fact same as at 32L476GDISCOVERY), I measure at Vref+ 3.29V.

Any ideas to solve this issue are appreciated. Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
thomasflatz
Associate

I solved the issue meanwhile. In fact it was the calibration, but the way how I implemented it.

Before I just called

HAL_ADCEx_Calibration_Start(...)

followed by immediate conversation. That was obviously too short. Now I use a while statement

while(HAL_ADCEx_Calibration_Start(...) != HAL_OK);

which works fine now.

But thanks anyway!

View solution in original post

2 REPLIES 2

Did you calibrate the ADC as per Calibration (ADCAL, ADCALDIF, ADCx_CALFACT) subchapter of the ADC chapter of RM?

JW

thomasflatz
Associate

I solved the issue meanwhile. In fact it was the calibration, but the way how I implemented it.

Before I just called

HAL_ADCEx_Calibration_Start(...)

followed by immediate conversation. That was obviously too short. Now I use a while statement

while(HAL_ADCEx_Calibration_Start(...) != HAL_OK);

which works fine now.

But thanks anyway!