offset on the ADC
I want to read the Vdd (link to VDDA) of my board with the ADC in a STM32L072. I try read it through a divider bridge or through VrefInt, and both give me a value far below the voltmeter value.
here is my config:
hadc.Instance = ADC1;
hadc.Init.OversamplingMode = DISABLE;
hadc.Init.Oversample.Ratio = ADC_OVERSAMPLING_RATIO_8;
hadc.Init.Oversample.RightBitShift = ADC_RIGHTBITSHIFT_NONE;
hadc.Init.Oversample.TriggeredMode = ADC_TRIGGEREDMODE_SINGLE_TRIGGER;
hadc.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV1;
hadc.Init.Resolution = ADC_RESOLUTION_12B;
hadc.Init.SamplingTime = ADC_SAMPLETIME_160CYCLES_5;
hadc.Init.ScanConvMode = ADC_SCAN_DIRECTION_FORWARD;
hadc.Init.DataAlign = ADC_DATAALIGN_RIGHT;
hadc.Init.ContinuousConvMode = DISABLE;
hadc.Init.DiscontinuousConvMode = DISABLE;
hadc.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
hadc.Init.ExternalTrigConv = ADC_SOFTWARE_START;
hadc.Init.DMAContinuousRequests = DISABLE;
hadc.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
hadc.Init.Overrun = ADC_OVR_DATA_PRESERVED;
hadc.Init.LowPowerAutoWait = DISABLE;
hadc.Init.LowPowerFrequencyMode = ENABLE;
hadc.Init.LowPowerAutoPowerOff = ENABLE;
HAL_ADC_Init(&hadc);
hadc.Instance->CFGR1 = hadc.Instance->CFGR1 | ADC_CFGR1_WAIT;
/** Configure for the selected ADC regular channel to be converted. */
sConfig.Channel = ADC_CHANNEL_1;
sConfig.Rank = ADC_RANK_CHANNEL_NUMBER;
HAL_ADC_ConfigChannel(&hadc, &sConfig);
/** Configure Vrefint */
sConfig.Channel = ADC_CHANNEL_VREFINT;
HAL_ADC_ConfigChannel(&hadc, &sConfig);And to read, I just do twice (one for channel, one for Vref):
HAL_ADC_Start(&hadc);
HAL_ADC_PollForConversion(&hadc, 1000);
HAL_ADC_GetValue(&hadc);the results are:
channel1_count = 1047 => 1047 * Vdda(3.3V) / 4096 = 0.84V (multiply by the divider bridge = 3) = 2.53V
with VrefInt, I have:
VrefInt_count = 1575
VrefInt in register = 1674
1575 / 1674 * 3 = 2.82V
In both cases, I have too small voltage, I measured on a voltmeter, I have ~1.1V on the divider bridge, and 3.3V on Vdda (link to Vdd through a self).
Where is my mistake ? Is there something to check ?

