Detailed explanation of FreeRTOS: FreeRTOS program startup process (basics - 5)

When the bare-metal system is powered on, the reset function Reset_Handler compiled by assembly in the startup file is executed first. The reset function will finally call the C library function __main. The main job of the __main function is to initialize the system heap and stack, and finally call the C library function The main function. As shown below:

1. Create a task

In the main() function, we can directly create tasks for FreeRTOS, because FreeRTOS will automatically do initialization for us, such as initializing the heap memory. We directly initialize the board-level peripherals in the main() function - BSP_Init(), and then use the xTaskCreate() function to create tasks. In task creation, FreeRTOS will help us with system initialization and heap memory initialization.

The heap memory initialization inside the xTaskCreate() function is as follows:

The program description is as follows:

(1)(2) Once the xTaskCreate() function is called when the memory is not initialized, FreeRTOS will automatically initialize the memory for us. The code for memory initialization is as follows. Note that this function is called internally by FreeRTOS. For now, we don’t care about the implementation of this function. We will explain the memory management knowledge of FreeRTOS in detail later. Now we know that FreeRTOS will help us initialize the things that the system needs.

Guess you like

Origin blog.csdn.net/m0_38106923/article/details/131595331