FreeRTOS - Introduction

Created:2018-11-14  Last modified:2018-11-14


  1. Introduction

    FreeRTOS is a real time operating system for embedded devices that don't equip MMU (no virtual memory)

    In order to use FreeRTOS, you have to port FreeRTOS to the specific platform. Fortunately, there existed lots of FreeRTOS ports, such as for STM32F103

    FreeRTOS

    1. FreeRTOS scheduler

      FreeRTOS scheudler can be used as a preemptive priority based scheduler. The scheduler maintains serveral task lists, each task list is associated with a priority. In the STM32CubeMX example, there are

                          #define configMAX_PRIORITIES                     ( 7 ) // defined in FreeRTOSConfig.h
                      
      7 priorities.
      Therefore, the FreeRTOS has 7 thread ready lists. It also has 2 delayed task lists, 1 pending ready list, 1 suspended thread list and 1 waiting terminated list.

  2. STM32CubeMX FreeRTOS

    STM32CubeMX provide a FreeRTOS port for stm32 microcontrollers. The port has one extra layer, cmsis-os layer, which is a kind of uniform API layer defined by ARM in order to be able to run code on different OSes.

    For example, the create thread function in FreeRTOS is xTaskCreate(), but it is wrapped by osThreadCreate() in cmsis-os.

    But it is still possible to directly use the FreeRTOS API.

    Example

    1. When using FreeRTOS, it is recommended to use a timer as the timebase.
    2. Create thread inside the tool.

    Code structure

  3. References