Understanding FreeRTOSConfig.h Configuration File

Understanding FreeRTOSConfig.h Configuration File

Introduction

In addition to the “General Configuration” in the FreeRTOSConfig.h configuration file, the content of other configurations is relatively less used by beginners and is also relatively difficult to understand. To give beginners a general understanding, this article continues to discuss the content of FreeRTOSConfig.h configuration, and further discussions will be combined with applications in the future.

TIMERS Configuration

A TIMER is a timer, and in RTOS, a TIMER belongs to software timing. The precision of FreeRTOS timers is not high and will change as the timing increases, especially when the TIMER’s task priority is low and higher priority tasks occupy resources.

If high precision timing is required, hardware timers should be used (most processors now generally have multiple hardware TIMERS).

1.configUSE_TIMERS

Whether to use software timers

Set to 0: Do not use

Set to 1: Use

Many other related functions need to be combined with this configuration to be used, and care should be taken to see if they are related when using.

2.configTIMER_TASK_PRIORITY

Software timer task priority

Software timers actually require the creation of a task, which is done in the same way as our conventional tasks, but it is completed by the system kernel, and we do not need to write the task creation code ourselves.

The priority here is the priority of the timer task.

3.configTIMER_QUEUE_LENGTH

Software timer command queue length

The knowledge involved in the TIMER command queue is relatively complex, and will be further discussed later. See the figure below:

Understanding FreeRTOSConfig.h Configuration File

4.configTIMER_TASK_STACK_DEPTH

Stack space allocated to software timers

CO_ROUTINES Configuration

CO_ROUTINES is difficult to translate, and it is commonly called cooperative programs online, or cooperative routines, understood as programs that work together. Further discussions will be combined with applications.

1.configUSE_CO_ROUTINES

Whether to use CO_ROUTINES

Set to 0: Do not use

Set to 1: Use

2.configMAX_CO_ROUTINE_PRIORITIES

CO_ROUTINE priority

MEMORY Configuration

Memory allocation related configuration, this configuration is related to heap_x.c, which will be discussed again later.

1.configSUPPORT_STATIC_ALLOCATION

Whether to support static allocation

Set to 0: Do not support

Set to 1: Support

2.configSUPPORT_DYNAMIC_ALLOCATION

Whether to support dynamic allocation

Set to 0: Do not support

Set to 1: Support

3.configTOTAL_HEAP_SIZE

Heap allocated to the system

Memory for creating tasks, stacks, and both static and dynamic allocations comes from here.

4.configAPPLICATION_ALLOCATED_HEAP

Where the APP allocates the heap

Set to 0: Use system allocated heap

Set to 1: Use externally allocated heap

The default is to use the system allocated heap, see the definition below:

#if(configAPPLICATION_ALLOCATED_HEAP == 1 )

extern uint8_t ucHeap[configTOTAL_HEAP_SIZE];

#else

static uint8_t ucHeap[configTOTAL_HEAP_SIZE];

#endif

RUN_TIME_STATS Configuration

Runtime statistics configuration

1.configGENERATE_RUN_TIME_STATS

Whether to generate statistics

Set to 0: No

Set to 1: Yes

2.configUSE_TRACE_FACILITY

Whether to assist in visualization and tracing

Set to 0: No

Set to 1: Yes

This will add additional structures to implement.

3.configUSE_STATS_FORMATTING_FUNCTIONS

Whether to provide statistical related functions

Set to 0: No

Set to 1: Yes

Setting macros configUSE_TRACE_FACILITY and configUSE_STATS_FORMATTING_FUNCTIONS to 1 will compile vTaskList() and vTaskGetRunTimeStats() functions. If either of these macros is set to 0, the above two functions will not be compiled.

Other Configurations

Here is a brief overview of various configurations

1.configASSERT

Assertion configuration

2.Interrupt related

configKERNEL_INTERRUPT_PRIORITY: Kernel interrupt priority

configMAX_SYSCALL_INTERRUPT_PRIORITY: Maximum priority for system calls

configMAX_API_CALL_INTERRUPT_PRIORITY: Maximum priority for API calls

This section is related to (Cortex) kernel hardware interrupts.

3.INCLUDE Configuration

#define INCLUDE_vTaskPrioritySet 1

#define INCLUDE_uxTaskPriorityGet 1

#define INCLUDE_vTaskDelete 1

This is easy to understand, whether to include these contents, which is quite common in UCOS.

Conclusion

Recommended reading:

FreeRTOSConfig.h Configuration File (1) – General Configuration

FreeRTOSConfig.h Configuration File (2) – HOOK Functions

WeChat search “EmbeddDeveloper” or scan the QR code below to follow and see more exciting content in my bottom menu!

Understanding FreeRTOSConfig.h Configuration File

Long press to identify the QR code to follow

Understanding FreeRTOSConfig.h Configuration File

Understanding FreeRTOSConfig.h Configuration File

Leave a Comment

×