Skip to main content
Graduate II
May 19, 2025
Solved

STM32G491 ADC results 2–3 times higher than expected

  • May 19, 2025
  • 2 replies
  • 436 views

Hi,

We are currently implementing ADC on the STM32G491 MCU using ADC2, Channel 15, with Vref set to 3.3V.

The ADC configuration is as shown below:

 hadc2.Instance = ADC2;
 hadc2.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV2;
 hadc2.Init.Resolution = ADC_RESOLUTION_12B;
 hadc2.Init.DataAlign = ADC_DATAALIGN_RIGHT;
 hadc2.Init.GainCompensation = 0;
 hadc2.Init.ScanConvMode = ADC_SCAN_DISABLE;
 hadc2.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
 hadc2.Init.LowPowerAutoWait = DISABLE;
 hadc2.Init.ContinuousConvMode = DISABLE;
 hadc2.Init.NbrOfConversion = 1;
 hadc2.Init.DiscontinuousConvMode = DISABLE;
 hadc2.Init.ExternalTrigConv = ADC_SOFTWARE_START;
 hadc2.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
 hadc2.Init.DMAContinuousRequests = DISABLE;
 hadc2.Init.Overrun = ADC_OVR_DATA_PRESERVED;
 hadc2.Init.OversamplingMode = DISABLE;
 if (HAL_ADC_Init(&hadc2) != HAL_OK)
 {
 Error_Handler();
 }

 /** Configure Regular Channel
 */
 sConfig.Channel = ADC_CHANNEL_15;
 sConfig.Rank = ADC_REGULAR_RANK_1;
 sConfig.SamplingTime = ADC_SAMPLETIME_92CYCLES_5;
 sConfig.SingleDiff = ADC_SINGLE_ENDED;
 sConfig.OffsetNumber = ADC_OFFSET_NONE;
 sConfig.Offset = 0;
 if (HAL_ADC_ConfigChannel(&hadc2, &sConfig) != HAL_OK)
 {
 Error_Handler();
 }

However, when using 3.3V as the reference voltage for our voltage calculations, we are observing results that are 2–3 times higher than expected. When we use a lower Vref value, the calculated voltages are closer to the actual values.

We would like to understand how Vref is handled internally by the MCU.
Is there any way to verify the internal reference voltage being used?

    This topic has been closed for replies.
    Best answer by waclawek.jan

    The ADC's reference voltage is always the voltage of VREF+ pin against VREF- pin. In smaller packages, VREF+ is internally bonded to VDDA, VREF- to VSS.

    So simply measure voltage on those pins (directly on the pins). Also, you can try to perform ADC conversion of the internal VREFINT reference voltage, which has a known voltage (see datasheet).

    What is your signal source?

     

     

    2 replies

    Technical Moderator
    May 19, 2025

    Hello,

    Did you calibrate the ADC before starting the conversion?

     /* Run the ADC calibration in single-ended mode */
     if (HAL_ADCEx_Calibration_Start(&hadc2, ADC_SINGLE_ENDED) != HAL_OK)
     {
     /* Calibration Error */
     Error_Handler();
     }
    Super User
    May 19, 2025

    The ADC's reference voltage is always the voltage of VREF+ pin against VREF- pin. In smaller packages, VREF+ is internally bonded to VDDA, VREF- to VSS.

    So simply measure voltage on those pins (directly on the pins). Also, you can try to perform ADC conversion of the internal VREFINT reference voltage, which has a known voltage (see datasheet).

    What is your signal source?