Getting started with FreeRTOS ¶
FreeRTOSConfig.h is the central configuration file that customizes the FreeRTOS kernel for user specific project, MCU, and requirements. It defines:
Scheduler behavior and tick rate.
Number of priorities and stack sizes.
Enabled kernel features: timers, event groups, mutexes, hooks, etc.
Memory allocation model and heap size.
Interrupt priority scheme and ISR-safe API usage.
Every project typically has a custom
FreeRTOSConfig.htuned to its performance, memory, and safety requirements.
Configuration file ¶
FreeRTOSConfig.h
is
project-specific
. It controls which features
are compiled and how the kernel behaves. It is included indirectly by
FreeRTOS.h.
Typical configuration items:
Scheduler options:
configUSE_PREEMPTIONconfigUSE_TIME_SLICINGconfigUSE_TICKLESS_IDLE
Timing and priorities:
configTICK_RATE_HZconfigMAX_PRIORITIESconfigMINIMAL_STACK_SIZEconfigUSE_16_BIT_TICKS
Enabling/disabling features:
configUSE_MUTEXESconfigUSE_RECURSIVE_MUTEXESconfigUSE_COUNTING_SEMAPHORESconfigUSE_TIMERSconfigUSE_EVENT_GROUPSHook functions (idle hook, tick hook, etc.).
Memory allocation:
configSUPPORT_STATIC_ALLOCATIONconfigSUPPORT_DYNAMIC_ALLOCATIONconfigTOTAL_HEAP_SIZE(for heap_1/2/4/5).
Port-specific settings (for example, Cortex-M interrupt priorities):
configKERNEL_INTERRUPT_PRIORITYconfigMAX_SYSCALL_INTERRUPT_PRIORITYconfigLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY
Configuration options & files ¶
This table lists commonly used configuration macros from
FreeRTOSConfig.h
with a short description, typical values, and links
to the official FreeRTOS documentation.
|
Macro |
Description |
Link |
|---|---|---|
|
|
CPU clock frequency in Hz, used by the port layer (SysTick, timers).
Example:
|
|
|
|
RTOS tick frequency in Hz. Defines the tick period and timing granularity.
Common values:
|
|
|
|
Number of priority levels available for tasks.
Typical:
|
|
|
|
Stack size (in words, not bytes) for the Idle task and small tasks.
Depends on MCU/port; e.g.
|
|
|
|
Total heap size used by
|
|
|
|
Enable (1) or disable (0) preemptive scheduling.
Typically
|
|
|
|
If 1, calls
|
|
|
|
If 1, calls
|
|
|
|
If 1, calls
|
|
|
|
Enable stack overflow checking. 0 = disabled, 1/2 = different methods.
Recommended
|
|
|
|
Enable time slicing between tasks of the same priority.
Usually
|
|
|
|
Use 16‑bit tick type instead of 32‑bit to save memory on small MCUs.
Typically
|
|
|
|
Enable mutex support (priority inheritance).
Typically
|
|
|
|
Enable recursive mutexes.
Set to
|
|
|
|
Enable counting semaphores.
Typically
|
|
|
|
Enable queue sets (multiplexing queues/semaphores).
Set to
|
|
|
|
Enable software timers and the timer service task.
Typically
|
|
|
|
Priority of the timer service task (when
|
|
|
|
Stack depth (in words) for the timer service task.
Depends on callbacks; e.g.
|
|
|
|
Length of the timer command queue.
Example:
|
|
|
|
Control inclusion of
|
|
|
|
Control inclusion of
|
|
|
|
Control inclusion of
|
|
|
|
Control inclusion of
|
|
|
|
Control inclusion of
|
|
|
|
Enable direct‑to‑task notifications for the idle task. Optional, depending on design. |
|
|
|
Enable direct‑to‑task notification API.
Typically
|
|
|
|
Enable trace and debug functions like
|
|
|
|
Enable generation of run‑time stats per task.
|
|
|
|
Enable tickless idle (low‑power) mode when the system is idle.
Often
|
|
|
|
Max interrupt priority (Cortex‑M) from which FreeRTOS API can be called.
Must match NVIC config; typical:
|
|
|
|
Lowest NVIC priority used by the system (Cortex‑M helper macro). Used with ST/CMSIS macros (e.g. 15 for 4 bits of priority). |
|
|
|
Highest NVIC priority allowed to call FreeRTOS API (Cortex‑M helper).
Example:
|
|
|
|
Kernel interrupt priority (legacy style on some ports).
Usually derived from
|
FreeRTOS APIs description ¶
|
FreeRTOS API Functions |
Description |
Link |
|---|---|---|
|
|
Create a new task (dynamic or static allocation). |
|
|
|
Delete a task. |
|
|
|
Delay a task for a relative time period. |
|
|
|
Implement periodic execution using an absolute reference time. |
|
|
|
Change or retrieve a task’s priority. |
|
|
|
Suspend and resume a task. |
|
|
|
Get the minimum ever free stack space for a task (stack high-water mark). |
|
|
|
Start the RTOS scheduler (should not return). |
|
|
|
End the scheduler (supported only on some ports). |
|
|
|
Create a message queue (dynamic or static allocation). |
|
|
|
Send an item to a queue from a task. |
|
|
|
Receive an item from a queue. |
|
|
|
Queue send/receive operations from an ISR. |
|
|
|
Create and delete a binary semaphore. |
|
|
|
Create a counting semaphore. |
|
|
|
Take and give a semaphore from a task context. |
|
|
|
Give a semaphore from an ISR context. |
|
|
|
Create a mutex (standard or recursive) with priority inheritance. |
|
|
|
Take and give a recursive mutex. |
|
|
|
Create and use event groups for task synchronization. |
|
|
|
Create a software timer (dynamic or static allocation). |
|
|
|
Start, stop or change the period of a software timer. |
|
|
|
Direct-to-task notifications (lightweight event/queue alternative). |
|
|
|
Allocate and free memory from the FreeRTOS heap. |
|
|
|
Generate a human-readable table of task states and stack usage. |
|
|
|
Get run-time statistics (CPU usage) for each task. |
Links ¶
What is FreeRTOS? : What is FreeRTOS ?