Can I use the blocking API in RTOS's tasks?
Hi there,
I have an IIC sensor connected to the MCU. And I read the sensor data at 50Hz.
However, there are sometimes some IIC communication errors present with HAL_I2C_ERROR_TIMEOUT.
My project is based on FreeRTOS with 4 Tasks, the sensor data collection task is one of the tasks, and the priority of this one isn't the highest.
I try to read the sensor data by the blocking API "HAL_I2C_Master_Transmit()" and "HAL_I2C_Master_Receive()".
I want to know if is there any possibility that the HAL_I2C_ERROR_TIMEOUT is caused by the blocking API in the sensor data collection task being interrupted by higher-priority tasks.
If yes, how to modify the code? Change to "HAL_I2C_Master_Transmit_IT()" and "HAL_I2C_Master_Receive_IT()" is OK?
(Because the frequency of the error is very low, it's not easy to position the root reason by test.)
(And can't include "HAL_I2C_Master_Transmit()" and "HAL_I2C_Master_Receive()" in "taskENTER_CRITICAL()" and "taskExit_CRITICAL()" to keep others task's realtime)
Thanks for your help!
