Hello,
I am having an issue with task delay. I have two tasks with the same priority. One task is dealing with the transmitting of CAN messages cyclically. This task updates the tick of each message object and when tick reaches cycle time, it sends the message. This task is delayed using vTaskDelay(10).
Another task has to read data from the internal ADC which will be later send through CAN. This task uses while loop to check if the conversion is complete:
while ((adcIsConversionComplete(adcREG1, adcGROUP1)) == 0);
Everything is fine when the ADC is enabled but when the ADC is disabled, MCU is stuck inside while loop. This causes some deviations in my other task that sends CAN messages. Cycle times are messed up.
Since I don’t have much experience in FreeRTOS, I would like to know how should I solve this problem. Of course, I can enable ADC and everything is fine. But, I would like that my task that sends messages is executed every 10 ms, no matter what. What is the strategy for long busy-wait loops like the one above? Should I replace it with an if and switch the context?
I thought that task will be preempted and switched to another task because task delay is used but as I see the while loop is messing execution time.
Thank you in advance
Greetings