IntroductionThis simple demo project runs on the STM32 Discovery board, which is populated with an STM32F100RB Cortex-M3 microcontroller from STMicroelectronics.
Its low cost makes the discovery board an ideal evaluation platform, but the 8K of RAM available also means there is a limit to the number of FreeRTOS kernel features that can be demonstrated. Therefore, this simple demo only actively demonstrates task, queue, software timer and interrupt functionality. The demo is also configured to include malloc failure, idle, and stack overflow hook functions.
The FreeRTOS download includes other, more fully featured, demonstration applications for larger parts in the STM32 microcontroller family.
The demo is pre-configured to use the free version of the Atollic TrueStudio for STM32 Eclipse based IDE, along with the FreeRTOS GCC port.
IMPORTANT! Notes on using the STM32F100 ARM Cortex-M3 DemoPlease read all the following points before using this RTOS port.
My application does not run, what could be wrong?
Source Code OrganisationThe FreeRTOS download contains the source code for all the FreeRTOS ports so includes many more files than are required for this demo. See the Source Code Organization section for a description of the downloaded files and information on creating a new project.
The TrueStudio project for the FreeRTOS STM32 Discovery Board demo is located in the FreeRTOS/Demo/CORTEX_STM32F100_Atollic directory. This is the project that should be imported into the TrueStudio workspace. The Preparing the Eclipse Project section below contains important information on setting up the demo project directory, and importing the demo project into TrueStudio.
The Demo Application
Demo application hardware set upThe demo uses the LEDs and buttons that are integrated onto the STM32 Discovery board hardware. Therefore, no hardware set up is required.
CreateProjectDirectoryStructure.bat must be executed before the TrueStudio project is imported into the Eclipse workspace.
CreateProjectDirectoryStructure.bat cannot be executed from within the TrueStudio Eclipse IDE.
Importing the demo application project into the TrueStudio Eclipse workspaceTo import the STM32 TrusStudio project into an existing or new Eclipse Workspace:
Building and running the demo application
The dialogue box used to create a debug launch configuration after the
"New Launch Configuration" speed button (highlighted in red) has been pressed.
RTOS Configuration and Usage Details
RTOS port specific configurationConfiguration items specific to these demos are contained in FreeRTOS/Demo/CORTEX_STM32F100_Atollic/Simple_Demo_Source/FreeRTOSConfig.h. The constants defined in FreeRTOSConfig.h can be edited to meet the needs of your application. In particular -
Attention please!: Remember that ARM Cortex-M3 cores use numerically low priority numbers to represent HIGH priority interrupts. This can seem counter-intuitive and is easy to forget! If you wish to assign an interrupt a low priority do NOT assign it a priority of 0 (or other low numeric value) as this will result in the interrupt actually having the highest priority in the system - and therefore potentially make your system crash if this priority is above configMAX_SYSCALL_INTERRUPT_PRIORITY. Also, do not leave interrupt priorities unassigned, as by default they will have a priority of 0 and therefore the highest priority possible.
The lowest priority on a ARM Cortex-M3 core is in fact 255 - however different Cortex-M3 vendors implement a different number of priority bits and supply library functions that expect priorities to be specified in different ways. For example, on the STM32 the lowest priority you can specify in an ST driver library call is in fact 15 - this is defined by the constant configLIBRARY_LOWEST_INTERRUPT_PRIORITY in FreeRTOSConfig.h. The highest priority that can be assigned is always zero.
It is also recommended to ensure that all four priority bits are assigned as being premption priority bits. This can be ensured by passing "NVIC_PriorityGroup_4" into the ST library function NVIC_PriorityGroupConfig(). In the demo project this is done from the function prvSetupHardware(), which is itself defined in main.c.
Each port #defines 'BaseType_t' to equal the most efficient data type for that processor. This port defines BaseType_t to be of type long.
Note that vPortEndScheduler() has not been implemented.
Interrupt service routinesUnlike most ports, interrupt service routines that cause a context switch have no special requirements and can be written as per the compiler documentation. The macro portEND_SWITCHING_ISR() can be used to request a context switch from within an ISR.
Note that portEND_SWITCHING_ISR() will leave interrupts enabled.
This demo project provides an example interrupt service routines - namely EXTI0_IRQHandler() defined in main.c.
Note that the following lines are included in FreeRTOSConfig.h:
#define vPortSVCHandler SVC_Handler #define xPortPendSVHandler PendSV_Handler #define xPortSysTickHandler SysTick_HandlerThese definitions map the FreeRTOS kernel interrupt handler function names onto the CMSIS interrupt handler functions names - and in so doing, allow the Atollic provided linker script and start up files to be used without modification.
Switching between the pre-emptive and co-operative RTOS kernelsSet the definition configUSE_PREEMPTION within FreeRTOS/Demo/CORTEX_STM32F100_Atollic/Simple_Demo_Source/FreeRTOSConfig.h to 1 to use pre-emption or 0 to use co-operative.
Memory allocationSource/Portable/MemMang/heap_1.c is included in the ARM Cortex-M3 demo application project to provide the memory allocation required by the RTOS kernel. Please refer to the Memory Management section of the API documentation for full information.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.
Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019
Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.
View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.
FreeRTOS and other embedded software careers at AWS.