🌐
Medium
aliafshar.medium.com › esp-idf-tutorials-part-2-delay-75a6c29e05e4
ESP-IDF for Arduino Users, Tutorials Part 2: Delay | by Ali Afshar | Medium
January 6, 2021 - https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/freertos.html · Delay doesn’t have to block like Arduino. Delay some milliseconds like this: vTaskDelay(pdMS_TO_TICKS(10)); Since vTaskDelay accepts ticks, the ...
🌐
GitHub
github.com › espressif › esp-idf › issues › 8584
vTaskDelay inaccurate (IDFGH-6964) · Issue #8584 · espressif/esp-idf
March 16, 2022 - static void TIMER_TEST_TASK(void* parameters) { static int counter = 0; for(;;) { counter++; int64_t task_execution_start = esp_timer_get_time()/1000; // get current time required for the task delay ESP_LOGW("TEST","time in miliseconds=%lli",task_execution_start); ESP_LOGW("TEST","PRINT STATEMENT FOR ADDITIONAL DELAY "); ESP_LOGW("TEST","PRINT STATEMENT FOR ADDITIONAL DELAY "); ESP_LOGW("TEST","PRINT STATEMENT FOR ADDITIONAL DELAY "); ESP_LOGW("TEST","PRINT STATEMENT FOR ADDITIONAL DELAY "); ESP_LOGW("TEST","PRINT STATEMENT FOR ADDITIONAL DELAY "); if(counter == 5 ){ ESP_LOGW("TEST","PRINT STA
Author   espressif
Discussions

vTaskDelay with long wait times
"The constant port TICK_PERIOD_MS can be used to calculate real time from the tick rate - with the resolution of one tick period." More on reddit.com
🌐 r/esp32
25
9
October 24, 2023
`FreeRtos::delay_us` will block for less than the given time for fractional milliseconds
embedded_hal states that delay_us: Pauses execution for at minimum us microseconds. Pause can be longer if the implementation requires it due to precision/timing issues. The following line always r... More on github.com
🌐 github.com
5
April 15, 2022
c - ESP IDF: Task never leaves vTaskDelay() - Stack Overflow
I am building a system that creates a WLAN AP over which the end user can Connect/disconnect the ESP to another AP ( For example a router) by posting a JSON String to a URL. In APSTA mode. When thi... More on stackoverflow.com
🌐 stackoverflow.com
delay() function doesn't work for less than 10ms
Hardware: Board: Lolin32 Core Installation version: d5fdd71 IDE name: IDF component Flash Frequency: 40Mhz PSRAM enabled: no Upload Speed: 115200 Computer OS: Windows 8.1 Description: delay() doesn't work for periods smaller than one tic... More on github.com
🌐 github.com
15
July 11, 2019
🌐
ESP32 ESP-IDF
esp32tutorials.com › home › esp32 esp-idf freertos timer and delay using esp-idf
ESP32 ESP-IDF FreeRTOS Timer and Delay using ESP-IDF
August 15, 2022 - However, the vTaskDelay() function is not very accurate for very small values of delay. Let us test this. In the following code, we are obtaining the timer values after a delay of 1 milliseconds.
🌐
Espressif
docs.espressif.com › projects › esp-idf › en › v4.3 › esp32 › api-reference › system › freertos.html
FreeRTOS - ESP32 - — ESP-IDF Programming Guide v4.3 documentation
Delay a task for a given number of ticks. The actual time that the task remains blocked depends on the tick rate. The constant portTICK_PERIOD_MS can be used to calculate real time from the tick rate - with the resolution of one tick period. INCLUDE_vTaskDelay must be defined as 1 for this ...
🌐
Reddit
reddit.com › r/esp32 › vtaskdelay with long wait times
r/esp32 on Reddit: vTaskDelay with long wait times
October 24, 2023 -

Hello,

I am working on a project in IDF with FreeRTOS. Among all the tasks, the project has one task that needs to run every day at midnight (00:00 UTC). To do this, I have an external RTC with which I calculate how many seconds are left until midnight (I have verified that the calculation is correct). From there, I convert it to milliseconds and calculate the number of ticks to wait using pdMS_TO_TICKS(), passing this tick number to vTaskDelay(). However, the task runs much earlier. Does anyone know why this might be? The Tick rate (Hz) is 1000.

On the other hand, I have verified that when I convert X milliseconds to ticks using pdMS_TO_TICKS() and then calculate how many milliseconds those ticks are with pdTICKS_TO_MS(), the milliseconds value does not match the initial one. Does anyone know why this might be? Here's an example:

43200 seconds to milliseconds: 43200000
43200 seconds to ticks: 250327 
43200000 milliseconds to ticks: 250327 
250327 ticks to milliseconds: 250327

Thank you very much in advance.

🌐
ESP32 Forum
esp32.com › viewtopic.php
IDF documentation suggests microsecond delay - should be millisec - ESP32 Forum
December 8, 2018 - For example, when esp_wifi_start returns ESP_ERR_NO_MEM, the recoverable-error code vTaskDelay can be called, in order to get a microseconds’ delay for another try. Suggested change -- change "microseconds" to "milliseconds" because vTaskDelay is based on FreeRTOS time tic which is in multiple milliseconds.
🌐
Espressif
docs.espressif.com › projects › esp-idf › en › stable › esp32 › api-reference › system › freertos_idf.html
FreeRTOS (IDF) - ESP32 - — ESP-IDF Programming Guide v6.0.2 documentation
Whereas vTaskDelay () specifies a wake time relative to the time at which the function is called, xTaskDelayUntil () specifies the absolute (exact) time at which it wishes to unblock. The macro pdMS_TO_TICKS() can be used to calculate the number of ticks from a time specified in milliseconds ...
🌐
ESP32 Forum
esp32.com › viewtopic.php
vTaskDelay issue bit me - ESP32 Forum
I had an issue with the chip delivering bad calibration data. The sdk for the chip needed 2msec. Turned out that vTaskDelay(2/portTICK_PERIOD_MS) wasn't waiting long enough. After looking in the IDF I see that portTICK_PERIOD_MS is 10. So that means any msec delay < 10 is zero.
🌐
ESP32 Forum
esp32.com › board index › english forum › discussion forum › esp-idf
vTaskDelay(pdMS_TO_TICKS(1000)); vs vTaskDelay(1000 / portTICK_PERIOD_MS); - ESP32 Forum
July 8, 2019 - ------------------- Memory utilization ... using vTaskDelay(x/ portTICK_PERIOD_MS) add more code. ... I think the only compelling reason is that the macro does the multiplication first and can be used with tick rates higher than 1000Hz without a division by zero error. (Although ESP-IDF doesn't support tick rates higher than 1000Hz.) For the same reason it may also be more accurate for some combinations of tick rate and delay in milliseconds...
Find elsewhere
🌐
ESP32 Forum
esp32.com › viewtopic.php
Understanding the vTaskDelay help - ESP32 Forum
Sometimes it delays for exactly 2 seconds but sometimes it misses 10ms. 1. I have ensured that this is the only task with priority 1. There are other tasks running in the background but they have priority 2 or higher. 2. I have disabled all interrupts. ... If you're using the default settings ...
🌐
GitHub
github.com › esp-rs › esp-idf-hal › issues › 62
`FreeRtos::delay_us` will block for less than the given time for fractional milliseconds · Issue #62 · esp-rs/esp-idf-hal
April 15, 2022 - embedded_hal states that delay_us: Pauses execution for at minimum us microseconds. Pause can be longer if the implementation requires it due to precision/timing issues. The following line always rounds down, resulting in a much shorter ...
Author   esp-rs
🌐
Stack Overflow
stackoverflow.com › questions › 74702362 › esp-idf-task-never-leaves-vtaskdelay
c - ESP IDF: Task never leaves vTaskDelay() - Stack Overflow
romkez Those comments are not from me, rather the official esp idf website "docs.espressif.com/projects/esp-idf/en/latest/esp32/…". I solved the issue, I will post an answer soon. And zou are right depending on the prioritz of the task it sometimes ran just once or not at all.
🌐
TechOverflow
techoverflow.net › 2020 › 04 › 09 › esp-idf-equivalent-to-arduino-delay
ESP-IDF equivalent to Arduino delay() | TechOverflow
May 6, 2026 - You can use the FreeRTOS API to provide a delay similar to the Arduino delay() function in the ESP-IDF framework. FreeRTOS is included in the PlatformIO ESP-IDF default configuration. ... After that, you can use vTaskDelay(...) to perform the delay.
🌐
Blogger
unpythonic.blogspot.com › 2021 › 01 › esp-idf-for-arduino-users-tutorials_18.html
ESP-IDF for Arduino Users, Tutorials Part 2: Delay
January 18, 2021 - https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/freertos.html · Delay doesn’t have to block like Arduino. Delay some milliseconds like this:vTaskDelay(pdMS_TO_TICKS(10)); Since vTaskDelay accepts ticks, the ...
🌐
Esp32developer
esp32developer.com › programming-in-c-c › delays › delays
Delays – ESP32 Developer
We’ve also found instances where (10 / portTICK_PERIOD_MS) results in a delay of 100mS regardless of the value used! Even vTaskDelay(10) does it.
🌐
ESP32 Forum
esp32.com › board index › english forum › discussion forum › esp32 arduino
vTaskDelay() vS. Delay() - ESP32 Forum
portTICK_PERIOD_MS = 10; vTaskDelay(1000 / portTICK_PERIOD_MS); // 1000/10 = 100 Ticks instead of Delay(1000)? And what is exactly one tick? Top · Sprite · Espressif staff · Posts: 10383 · Joined: Thu Nov 26, 2015 4:08 am · Quote · Postby Sprite » Sun Jul 09, 2017 2:45 am · Where do ...
🌐
GitHub
github.com › espressif › arduino-esp32 › issues › 2981
delay() function doesn't work for less than 10ms · Issue #2981 · espressif/arduino-esp32
July 11, 2019 - Board: Lolin32 Core Installation version: d5fdd71 IDE name: IDF component Flash Frequency: 40Mhz PSRAM enabled: no Upload Speed: 115200 Computer OS: Windows 8.1 · delay() doesn't work for periods smaller than one tick(10ms) (it is also rounded ...
Author   espressif
🌐
ESP32 Forum
esp32.com › viewtopic.php
vTaskDelay - ESP32 Forum
October 31, 2018 - Hello @ESP_Dazz This is link to github issue: https://github.com/espressif/esp-idf/issues/391 It's quite "old" (1st october 2018) but I still see time to time using also v3.1.1. There you can find some backtrace As written on github I have a task with only "20ms" of vTaskDelay. Could it be the cause? Thanks ... Hi @davdav I don't source of the problem is due to the delay duration or the number of tasks.
🌐
Reddit
reddit.com › r/esp32 › better explanation for vtaskdelay (freertos) ?
r/esp32 on Reddit: Better Explanation for vTaskDelay (FreeRTOS) ?
September 15, 2021 -

Hello,

I am currently working on a project that uses FreeRTOS to create a bunch of tasks to do things. The code was written be a former student and I have to implement some stuff and make it run a bit smoother but I can't really understand the FreeRTOS part especially when it comes to Delays and TaskDelays or someone also told me about yields.

As an example I have 2 Tasks:

  xTaskCreatePinnedToCore(
    Task1code, /* Function to implement the task */
    "Pubblish", /* Name of the task */
    8192,  /* Stack size in words */
    NULL,  /* Task input parameter */
    1,  /* Priority of the task */
    &Task1,  /* Task handle. */
    1);
    
  delay(100);
  xTaskCreatePinnedToCore(
    Task2Code, /* Function to implement the task */
    "Sensors", /* Name of the task */
    4096,  /* Stack size in words */
    NULL,  /* Task input parameter */
    2,  /* Priority of the task */
    &Task2,  /* Task handle. */
    1);

and the following functions :

void Task1code( void * parameter) {
  
  for (;;) {
    if (client.connected()) { 
      String temp = getData();
      vTaskDelay(800);
  
      if (!client.publish("topic", temp ())) {
        log_e("Couldnt publish to 'Topic' ");
        vTaskDelay(200);
      } 
    }
    delay(3000);
  }
}

void Task2code( void * parameter) {
  for (;;){
    getTempValue(); // reads some DS81B0 temperaturesensors over 1-wire
    delay(750);
  }
}

I am kind of unsure what vTaskDelay does in the first code as I cant really understand this page here https://www.freertos.org/a00127.html - Also, can I use normal delays in a extra task or is it bad ?

I would love if someone could explains me the vTaskDelay a bit more noob-friendly and maybe has some ideas on how to make that code run better ?

Edit:

Also I question would be is how to use vTaskDelayUntil()

Thanks !

🌐
ESP32 Forum
esp32.com › viewtopic.php
vTaskDelay() Doubt - ESP32 Forum
July 8, 2017 - Another question, in this line of code vTaskDelay(1000 / portTICK_PERIOD_MS); means that 1000*10 ms = 10s, but I know that it is a second delay so, the portTICK does something that i don't understand. Maybe my questions are a little easy, but I don't want doubts.