I want to run multiple tasks on the same core of my ESP32 via FreeRTOS. I'm using the Arduino IDE. As I understood, the task with lower priority is only run, when the task with higher priority is finished. But I want that if the high priority task delays itself, the low priority task is run until the delay is over. Then the high priority task should be continued.
I googled a bit and asked ChatGPT, but every website said another thing:
vTaskDelay()
or vTaskDelayUntil()
(Sources which say to use it: Arduino Forum, ChatGPT; Source which say to not use it: Arduino Forumsemaphores
(Sources which say to use it: Arduino Forum, ChatGPT; Source which say to not use it: Arduino ForumvTaskSuspend()
and vTaskResume()
(Source which say to use it: ChatGPT; Source which say to not use it: me)I've tried nothing of that. What is the best and easiest way to do it?
vTaskDelay
is the canonical way to delay task operation giving room for other tasks to run. Note that there is also taskYIELD()
, which – for a short moment in time – transfers control to the scheduler to do its thing.