What is the purpose of HAL_ADC_PollForConversion in STM32 HAL ADC code?
So I've been experimenting with the STM32 (F103RB) for a few weeks, but I'm unclear about the purpose of the
HAL_ADC_PollForConversion
function. It seems to have no effect on the ADC readings in my code. Here’s an example:
The 1st (with PollForConversion
):
Then the 2nd (without PollForConversion
):
From what I can see, whether I include PollForConversion
or not, the UART readings appear the same (although I’m not entirely sure if they truly are). Continuous mode is disabled. Could someone clarify what I might be missing?1 Reply
@Sterling the
HAL_ADC_PollForConversion
function makes sure the ADC conversion is finished before you grab the value. Without it, you might get an incomplete reading, which can lead to errors. Even though your readings seem okay without it, that's likely because of the delay in your loop. Using PollForConversion
just guarantees you're always getting accurate results.