2020-07-30 09:48 AM
Hello,
I see ADC examples that use the following functions:
1.HAL_ADC_PollForConversion.
2.HAL_ADC_GetValue.
Questions:
a. What's the difference between both functions ?
b. In my application I simply want to get the ADC voltage when a user sends a command. What function should I use ?
2020-07-30 11:28 AM
Hi, HAL_ADC_PollForConversion start the conversion in the selected channel and keep waiting till the conversion is done, after that you must to call HAL_ADC_GetValue to store the conversion value, you need to use both functions in this order. So, in you application just catch the command and call them both functions.
2020-07-30 11:35 AM
Recommend usage of HAL functions is found in the source file.
You can also inspect the code. HAL_ADC_GetValue merely reads the DR register. You will need to start and wait for the conversion using HAL_ADC_PollForConversion.
*** Execution of ADC conversions ***
==============================================================================
[..]
(#) ADC driver can be used among three modes: polling, interruption,
transfer by DMA.
*** Polling mode IO operation ***
=================================
[..]
(+) Start the ADC peripheral using HAL_ADC_Start()
(+) Wait for end of conversion using HAL_ADC_PollForConversion(), at this stage
user can specify the value of timeout according to his end application
(+) To read the ADC converted values, use the HAL_ADC_GetValue() function.
(+) Stop the ADC peripheral using HAL_ADC_Stop()
2020-07-30 11:53 AM
Thanks,
Where can I get this file ?
2020-07-30 12:00 PM
> Where can I get this file ?
It should be included in your project directory somewhere.
The latest version is also available here: