Using osDelay(1) and HAL_ADC_PollForConversion with 0 timeout in FreeRTOS environment.
Hi,
I'm using the NUCLEO-64 STM32L476RG and I am aware that it is very simple to start the ADC to get a reading in an analog port. One should however wait for the conversion to complete and the HAL library has the HAL_ADC_PollForConversion() function that can be called with a timeout value.
However, HAL_ADC_PollForConversion() enters in a loop until the ADC finishes conversion; and I would like to release the CPU to perform other tasks (in FreeRTOS) while the conversion happens.
Thus, I am thinking about calling HAL_ADC_PollForConversion() with a 0 timeout value and call osDelay(1) if the return is HAL_TIMEOUT. (This would be repeated until the return is HAL_OK.)
However, I noticed in the HAL_ADC_PollForConversion code that a timeout causes the following two lines to be called:
/* Update ADC state machine to timeout */
SET_BIT(hadc->State, HAL_ADC_STATE_TIMEOUT);
/* Process unlocked */
__HAL_UNLOCK(hadc);
Would this prevent the ADC to complete the conversion process?
Would calling the HAL_ADC_PollForConversion 2 or more times (most likely 2) cause any unforeseen issues?
(Note: I could use the interrupts to receive a notification of the end of conversion; however, the reading of the analog value is not time critical.)
bjbf
