2022-12-05 12:57 AM
Hello,
I am using STM32L011G4U7 and wants to get the adc value where it showed once and not it is giving 0 for the adc raw values. Also please let me know that in order to read the vcc that is 3.3 volts do I need to select VREFINT channel as well along with ADC pin?
Here's my code:
void ReadVCC(byte ATR[])
{
HAL_ADC_Start_IT(&hadc);
HAL_ADC_PollForConversion(&hadc, HAL_MAX_DELAY);
adcval = HAL_ADC_GetValue(&hadc);
HAL_Delay(1);
VDDA = VREF * (VREFINT_CAL / adcval);
ATR[6] = (uint8_t) (VDDA>>8); // MSB
ATR[7] = (uint8_t) (VDDA & 0x00FF); // LSB
}
result: adcval 0
VDDA 1
Solved! Go to Solution.
2022-12-06 09:23 PM
Look at an example for the proper usage of HAL_ADC commands.
Here is one of many:
2022-12-05 02:08 AM
For open adc channel, it will give garbage value between vcc and gnd.
Once the channel is connected with any voltage, it should give corresponding voltage value.
2022-12-05 04:38 AM
My adc pin is connected to voltage divider and it is giving 1024 raw value
2022-12-05 06:24 AM
I cant see channel configuration in this code. (HAL_ADC_ConfigChannel(.....) )
2022-12-06 09:23 PM
Look at an example for the proper usage of HAL_ADC commands.
Here is one of many:
2022-12-06 10:27 PM
Vdda is usually vdd. Vref is a bandgap fixed voltage as internal channel. Reading it makes vdd deductable. When vdd is lowered, vref converted value goes up, and reversibly.