[GD32L233C-START Review] - Transplanting Freertos real-time system
[Copy link]
GD32L233C system resources are configured with 256KB flash and 32KB SRAM , and Freertos can be used , which makes it convenient to operate the module in a real-time system. Let's transplant this real-time system first.
- Source files can be downloaded from the FreeRTOS official website. Download the FreeRTOSv202112.00.zip version. The package name has changed, and the internal version number is FreeRTOS Kernel V10.4.6 .
https://www.freertos.org/
- There are only 6 files related to the FreeRTOS kernel , namely list.c queue.c tasks.c croutine.c timers.c , event_groups.c. This file is located in FreeRTOS\Source
- For the file related to memory allocation, GD32L233C selects heap_4.c . This file is located in Source\portable\ MemMang .
- The codes related to porting include port.c and portmacro.h . These codes are not only related to the compiler but also to the platform ( MCU ). FreeRTOS first classifies the compiler as a major category and then the platform ( MCU ) as a minor category. Here, the Keil compiler is selected and the platform is the Cortex-M23 kernel . The FreeRTOS kernel provides ARMv8-M and ARM _ CM23 porting codes under GCC , which can be run on the secure or non-secure side . When running on the non-secure side, the user task can call the functions exported by the secure side software . I use the non-secure mode, so the selected file is located in FreeRTOS\Source\portable\GCC\ARM_CM23_NTZ\non_secure .
- In addition to the above content, FreeRTOS kernel related header files are also included. The file FreeRTOS\Source\include .
- Add FreeRTOS files to the project .
- Add the header file path of FreeRTOS file to the project
- Compile and it will prompt an error, saying there is no FreeRTOSConfig.h file . To write this file to configure the kernel , you need the relevant macro definitions in FreeRTOSConfig.h . Copy a FreeRTOSConfig.h from the demo to the project directory and modify it.
- Recompile
These functions are defined in gd32123x.it.c. Remove them from gd32123x.it.c and recompile .
- The following error occurred
1 ), vApplicationGetIdleTaskMemory is used when we use static methods to create tasks . After using static methods to create tasks, the configSUPPORT_STATIC_ALLOCATION macro is defined as 1 .
2 ) There is a macro configCHECK_FOR_STACK_OVE RF LOW in FreeRTOS to detect stack overflow. If it is configured to 0 , you don't need to worry about it. If it is configured to other values, you need to call the hook function after detecting stack overflow. This is very useful for debugging and should be enabled.
Add the hook function in the main.c file .
There is no problem in compiling
- Add a task
Realize LED control tasks
The 4 LEDs light up back and forth, forming a back and forth running pattern.
Compile and download to achieve the expected result.
|