Free RTOS
Free RTOS
Free RTOS
FreeRTOS Overview
ESP-IDF FreeRTOS Overview
• Lesson content
• ESP-IDF RTOS differences from Vanilla FreeRTOS and ESP-IDF application startup
• Use of vTaskDelay
FreeRTOS Resources
• FreeRTOS is a real-time operating system kernel for embedded devices.
• FreeRTOS task stack size is specified in Bytes in ESP-IDF FreeRTOS not Words.
• xTaskCreate → Lets the ESP-IDF FreeRTOS choose which core the task runs on.
• xTaskCreatePinnedToCore → Allows for specifying which core the task runs on.
xTaskCreatePinnedToCore Parameters
BaseType_t xTaskCreatePinnedToCore(TaskFunction_t pvTaskCode, const char *const pcName, const uint32_t usStackDepth,
void *const pvParameters, UBaseType_t uxPriority, TaskHandle_t *const pvCreatedTask, const BaseType_t xCoreID)
• pvTaskCode → This is the custom C function (task) that runs in an infinite loop.
• pcName → Descriptive name for the task. Only used as a debugging aid.
• usStackDepth → Memory in bytes that should be allocated by the kernel to the task.
• uxPriority → The priority at which the task should run on. Higher priority number
takes precedence.
• pvCreatedTask → Optional task handle by which the created task can be referenced,
e.g., if you need to use various FreeRTOS APIs, like, vTaskDelete.
• xCoreID → The core of the ESP32 the task is assigned to (Core 0 or Core 1).
FreeRTOS Tasks
• FreeRTOS task states → https://www.freertos.org/RTOS-task-states.html
• Blocked → Because of temporal event, e.g., call to vTaskDelay or external event, e.g.,
waiting for a queue, semaphore, event group, notification or semaphore event.
• Suspended → There is no timeout and tasks only enter and exit the Suspended state
when explicitly commanded to do so using vTaskSuspend or xTaskResume API calls.
vTaskDelay
• vTaskDelay is used to send a task into Blocked state for a set 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.
Next lesson