Enthernet Code
Enthernet Code
DIIDevHeads IoT Integration Server
Created by youcef_ali on 8/6/2024 in #middleware-and-os
How to Implement a 6-Hour Delay in FreeRTOS Task?
@youcef_ali vTaskDelay takes the delay period in ticks, you need to convert the 6 hours into ticks based on your system's tick rate. Normally, u'll are to multiply the number of seconds in 6hours with your ticks per second which would result in a very high number and using large value isn't ideal so a better approach would be using a loop i.e 👇 (this is assuming ur tick is 1000/sec)
#define HOUR_TICKS (3600000) // 1 hour in ticks

void vTaskFunction(void *pvParameters)
{
for (;;)
{
// Perform your task here


for (int i = 0; i < 6; i++)
{
vTaskDelay(HOUR_TICKS);
}
}
}
#define HOUR_TICKS (3600000) // 1 hour in ticks

void vTaskFunction(void *pvParameters)
{
for (;;)
{
// Perform your task here


for (int i = 0; i < 6; i++)
{
vTaskDelay(HOUR_TICKS);
}
}
}
6 replies