cancel
Showing results for 
Search instead for 
Did you mean: 

ADC_IN0 on F030K6 not reading 3V3 voltage_divider

WBria.1
Associate II

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);

1 ACCEPTED SOLUTION

Accepted Solutions

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

2 REPLIES 2

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
WBria.1
Associate II

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.