2026-05-12 11:18 PM
Hello all!
I need some rubber ducking help here.
I have got hold of a B-U585I-IOT02A dev board, where I'm trying to get learn and get to know the STM32 family.
I have got a lot of things working, but the ADC1 is giving me a hard time:
Here is my MX config:
IN1 enabled, and expecting the data to be stored in the DR register.
PC0 is selected as ADC1_IN1:
Global interrupts are enabled:
So far, so good( I think ).
my application code:
/* Running in my main while(1) loop */
// Other stuff before here
if (StartConv) {
if (HAL_ADC_Start_IT(&hadc1) != HAL_OK)
{
/* Start Conversation Error */
Error_Handler();
}
StartConv = 0;
}
HAL_Delay(10);And when above is executed, I can see that I'm getting a interrupt and call to my own ConversionCallback function:
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* AdcHandle)
{
/* Get the converted value of regular channel */
adc_raw = HAL_ADC_GetValue(AdcHandle);
printf("ADC Raw Value: %lu\r\n", adc_raw);
// Retrigger convertion
StartConv = 1;
}(Remember folks, this is just for learning, I would never but a printf call in my ISR ;) )
And the prints i'm getting:
Fluctuating values between 0 and 2:
"But hey, have he even applied any voltage on the PC0 pin?" you might be thinking.
And the answer is: Yes, I have tried to direct hot wire the 3.3V pin from connector CN17.
I have also tried to use a potentiometer(This is my standard setup):
When I measure the PC0 pin (Green cable in my setup), I can see that it is between 0 and 3.3V based on the potentiometer position.
I base the board pins on the documentation:
So, so far during my rubber ducking session I have not found the problem!
Can someone else see my probably n00b mistake?
Solved! Go to Solution.
2026-05-13 3:00 AM - edited 2026-05-13 3:00 AM
Rubber ducking success!!
After re-reading my own post here, and playing around with the CubeMX settings for the ADC, I finally got it to work.
After changing "Enable Regular Conversions" to Enable, it magically started to work.
But... I do not now know why.....
2026-05-13 3:00 AM - edited 2026-05-13 3:00 AM
Rubber ducking success!!
After re-reading my own post here, and playing around with the CubeMX settings for the ADC, I finally got it to work.
After changing "Enable Regular Conversions" to Enable, it magically started to work.
But... I do not now know why.....