Skip to content

FreeRTOS.ino: fix usage of vTaskDelay #7418

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions libraries/ESP32/examples/FreeRTOS/FreeRTOS.ino
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ void TaskBlink(void *pvParameters) // This is a task.
for (;;) // A Task shall never return or exit.
{
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
vTaskDelay(100); // one tick delay (15ms) in between reads for stability
// arduino-esp32 has FreeRTOS configured to have a tick-rate of 1000Hz and portTICK_PERIOD_MS
// refers to how many milliseconds the period between each ticks is, ie. 1ms.
vTaskDelay(1000 / portTICK_PERIOD_MS ); // vTaskDelay wants ticks, not milliseconds
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
vTaskDelay(100); // one tick delay (15ms) in between reads for stability
vTaskDelay(1000 / portTICK_PERIOD_MS); // 1 second delay
}
}

Expand All @@ -92,6 +94,6 @@ void TaskAnalogReadA3(void *pvParameters) // This is a task.
int sensorValueA3 = analogRead(A3);
// print out the value you read:
Serial.println(sensorValueA3);
vTaskDelay(10); // one tick delay (15ms) in between reads for stability
vTaskDelay(100 / portTICK_PERIOD_MS); // 100ms delay
}
}