Home | Projects | Notes > Real-Time Operating Systems (RTOS) > FreeRTOS Task Delay APIs

FreeRTOS Task Delay APIs

 

FreeRTOS Task Delay APIs

1. vTaskDelay()

2. vTaskDelayUntil()

[!] Note: To learn more about these APIs, consult https://www.freertos.org/ Kernel API Reference Task Control. Make sure to understand the difference between these two APIs.

 

Why Use Them?

  1. Delay a task without engaging the processor (replacement for for/while loop based crude delay implementation)

    Use vTaskDelay().

  2. Implementation of periodic tasks

    Use vTaskDelayUntil().

    Periodic tasks:

    • Task which executes with a fixed execution period in the timeline.

    • To achieve fixed periodicity of a task, use vTaskDelayUntil() instead of vTaskDelay().

    • Fixed periodicity (i.e., task waking up and moving to the Ready state) is not guaranteed if vTaskDelay() is used to implement the periodic tasks.

 

Examples

1. vTaskDelay()

2. vTaskDelayUntil()

Milliseconds to Ticks Conversion

 

Summary

 

 

References

Nayak, K. (2022). Mastering RTOS: Hands on FreeRTOS and STM32Fx with Debugging [Video file]. Retrieved from https://www.udemy.com/course/mastering-rtos-hands-on-with-freertos-arduino-and-stm32fx/