Page 1 of 1

vTaskDelay below 10 ms

Posted: Tue Nov 12, 2024 5:27 pm
by AndreaS73
In my ESP32-S3 code I noticed that in my main loop I have to add `vTaskDelay(1)` otherwise I get a wdt reset.
I guess this is because if I don't suspend for a while my thread, the others cannot run.

Since `CONFIG_FREERTOS_HZ` is defined as 100, a delay of just 1 tick is 10 ms, too much!
Is there a way to suspend a task for less than a tick?
What may happen if I change that value to 1000? I mean, something bad can happen like UART or other timing-critical stuff?

Re: vTaskDelay below 10 ms

Posted: Tue Nov 12, 2024 11:55 pm
by ESP_Sprite
Mostly, the overhead of FreeRTOS is increased as its task switching code is called 10x more often. You're probably better off solving whatever issue you have in another way, though; isn't there a peripheral that can do what you want without involving the CPU too much?

Re: vTaskDelay below 10 ms

Posted: Wed Nov 13, 2024 8:00 am
by MicroController
Or, generally, try to use blocking function calls (mostly those whith a TickType_t maxwait parameter); and possibly create multiple tasks which can each handle different things and which block 'concurrently'.

Re: vTaskDelay below 10 ms

Posted: Wed Nov 13, 2024 1:02 pm
by DrMickeyLauer
This might be interesting for you: https://github.com/mickeyl/esp-microsleep