2022-01-12 09:50 AM
I'm pluging into ADC_IN0 1x pull-up and 5x buttons, that when i pressed some button, it adds a resistor to ground and make a voltage_divider... then i read the value on ADC.
But when i pressed the button, however, my ADC shows 0 on the variable and not the Vout from voltage_divider, like 1V or 0,5V.
I'm using CubeIDE with default ADC_IN0 config and making the while(1) as follow:
hadc.Instance->CHSELR |= ADC_CHSELR_CHANNEL(ADC_CHANNEL_0);
HAL_ADC_Start(&hadc);
HAL_ADC_PollForConversion(&hadc,10);
value_adc=HAL_ADC_GetValue(&hadc);
Solved! Go to Solution.
2022-01-12 09:59 AM
Make sure the pins and clocks are suitably configured.
Perhaps find another worked ADC example as a point of reference.
Try using existing library code rather than ORing values to a register.
2022-01-12 09:59 AM
Make sure the pins and clocks are suitably configured.
Perhaps find another worked ADC example as a point of reference.
Try using existing library code rather than ORing values to a register.
2022-01-12 10:03 AM
Tks Tesla,
Almost all of examples (from internet) uses the same sequence (1. config channel, 2. start the conversion, 3. poll... and then 4. read the value)
but yeas, i can try using some of the library example to test it.