vTaskDelay() Doubt

cherenkov11
Posts: 5
Joined: Fri Jul 07, 2017 5:59 am

vTaskDelay() Doubt

Postby cherenkov11 » Sat Jul 08, 2017 4:13 am

I have begun to interest in how FreeRTOS works, and because of I don't have my ESP32 yet, i decided to try it in my arduino micro. So, I note that the vTaskDelay in the arduino does a delay of 15ms because of the Watchdog timer, this is the piece of code that says it

Code: Select all

for (;;)
    {
      // read the input on analog pin 0:
      int sensorValue = analogRead(A0);
      // print out the value you read:
      Serial.println(sensorValue);
      vTaskDelay(1);  // one tick delay (15ms) in between reads for stability
    }
So, my question is, if I put a vTaskDelay(1) on my code, under ESP-IDF, What is the time that it took?.

I hope I have made myself clear, thank you.

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: vTaskDelay() Doubt

Postby WiFive » Sat Jul 08, 2017 4:32 am


cherenkov11
Posts: 5
Joined: Fri Jul 07, 2017 5:59 am

Re: vTaskDelay() Doubt

Postby cherenkov11 » Sat Jul 08, 2017 4:47 am

Thanks for answering so fast, so if I understand correctly, changing the value to 1000 hz (which is the max), will I get a 1ms delay?

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. Thank you.

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: vTaskDelay() Doubt

Postby WiFive » Sat Jul 08, 2017 5:42 am

portTICK_PERIOD_MS = 10
1000 / portTICK_PERIOD_MS = 100 ticks
100 * 10ms = 1 sec
However, a high tick frequency also means that the RTOS kernel will use more CPU time so be less efficient.

cherenkov11
Posts: 5
Joined: Fri Jul 07, 2017 5:59 am

Re: vTaskDelay() Doubt

Postby cherenkov11 » Sat Jul 08, 2017 6:06 am

Thank you very much, I appreciate the time you took to answer. :D

Who is online

Users browsing this forum: No registered users and 119 guests