Skip to content

mayankpatel97/FreeRTOS

Repository files navigation

Add FreeRTOS Manually in an STM32 Project. In this project, Ihave used an STM32F401 discovery board. Here are the steps that you can follow

  1. Open cube Mx and Generate a basic project with two LEDs as output.
  2. Download Free RTOS from the website "https://www.freertos.org/a00104.html"
  3. Extract the downloaded Zip and copy "FreeRTOS/source" folder in to your stm32 project.
  4. In the copied source folder, there is a portable folder. Delete all the file accept these two.

image

  1. Open source/poratble/GCC folder and delete all the folders inside it accept the one shown in the image

image

  1. Open source/poratble/MemMang and delete all the files accept "heap_4.c".

  2. In the downloaded FreeRTOS folder there is a folder called "Demo", open this and find "CORTEX_M4F_STM32F407ZG-SK" folder, there is a "FreeRTOSConfig.h" file inside it. Copy this file into inc folder of your stm32 project.

  3. make changes in "FreeRTOSConfig.h" as per the image below

image

  1. create "rtos_config.c" in to your project and add below code inside it.

    #include "FreeRTOS.h" #include "task.h"

void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize) { static StaticTask_t xIdleTaskTCB; static StackType_t uxIdleTaskStack[configMINIMAL_STACK_SIZE];

*ppxIdleTaskTCBBuffer = &xIdleTaskTCB;
*ppxIdleTaskStackBuffer = uxIdleTaskStack;
*pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;

}

void vApplicationGetTimerTaskMemory(StaticTask_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint32_t *pulTimerTaskStackSize) { static StaticTask_t xTimerTaskTCB; static StackType_t uxTimerTaskStack[configTIMER_TASK_STACK_DEPTH];

*ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
*ppxTimerTaskStackBuffer = uxTimerTaskStack;
*pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;

}

  1. Now FREE Rtos a is ready. create two tasks in main.c and toggle leds in both of them with 500ms delay.

About

Add FreeRTOS Manually in an STM32 Project

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages