I have a 485 task to talk slave device, and need wait some time to receive response data from slave device after sending command, i use following delay function to wait 50ms to be sure master can receive all response data from slave.
uint32_t i = 0;
for (i = 0; i < 30000; i++) ;
but the polling method waster more cpu resource indeed, i change it to vTaskDelay(50) to wait, the result is wrong data or less data received sometimes. I trace it and find that FreeRTOS call taskENTER_CRITICAL to mask all interrupt to protect some piece code. then taskEXIT_CRITICAL to enable all interrupt again. but it may cause 485 interrupt lose in this case. so master can’ t receive all data correctly, Is there a way to avoid this ?
apprecaite you in advance.