This page describes the FreeRTOS demo application for the STM32 Primer - a novel evaluation platform for the STMicroelectronics STM32 ARM Cortex-M3 microcontroller. The demo uses the GCC compiler with the Raisonance Ride V7 IDE.
The demo utilises drivers and other source files from CircleOS (which, unlike FreeRTOS.org, is not a real time kernel). These files are licensed separately from FreeRTOS.org. Users must familiarise themselves with the CircleOS license. Please note that the FreeRTOS demo is not itself a CircleOS application and will overwrite CircleOS on the STM32 Primer. The batch files located in the [Program Files]\Raisonance\Ride\Lib\ARM\CircleOS directory of your Raisonance Ride distribution can be used to restore CircleOS to the STM32 Primer hardware.
Using RIDE version 7: FreeRTOS V5.1.1 will not build with the latest versions of the RIDE libraries. The head revision in the FreeRTOS SVN repository has already been fixed - the necessary changes will be included in the next release.
Upgrading to FreeRTOS V5.0.3: FreeRTOS V5.0.3 introduced the configMAX_SYSCALL_INTERRUPT_PRIORITY configuration option to the ARM Cortex-M3 port. See the RTOS kernel configuration documentation for full information on this feature.
Upgrading to FreeRTOS V4.8.0: Prior to V4.8.0 the FreeRTOS kernel did not make use of the SVCall interrupt. From V4.8.0 onwards it does. Therefore, to upgrade an older project to the V4.8.0 standard, a small edit to the startup code is required. To do this, simply install vPortSVCHandler() in the SVCall position within the interrupt vector table (contained in the startup source file). The demo projects included in the FreeRTOS download have already been updated so these can be used as an example.
IMPORTANT! Notes on using the STM32 Primer 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 includes the source code for all the FreeRTOS ports and therefore contains 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 Ride workspace file for the STM32F103 Primer Ride demo is called RTOSDemo.rprj and is located in the FreeRTOS\Demo\CORTEX_STM32F103_Primer_GCC directory.
The Demo Application
Demo application hardware setupThe demo application uses the LED and display built onto the evaluation board so no specific hardware setup is required.
A USB interface is used to connect directly between the STM32 Primer and the host PC.
Building and running the demo applicationConnect the USB port marked "Debug" on the STM32 Primer to the host PC.
FunctionalityThe demo application creates 22 real time tasks. These tasks consist predominantly of the standard demo application tasks (see the demo application section for details of the individual tasks).
The following tasks and tests are created in addition to the standard demo tasks:
When executing correctly the demo application will behave as follows:
RTOS port specific configurationConfiguration items specific to these demos are contained in FreeRTOS/Demo/CORTEX_STM32F103_Primer_GCC/FreeRTOSConfig.h. The constants defined in this file can be edited to suit your application. In particular -
Attention please!: Remember that ARM Cortex-M3 cores use numerically low priority numbers to represent HIGH priority interrupts, which 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 can 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.
The lowest priority on a ARM Cortex-M3 core is in fact 255 - however different ARM 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 - and the highest priority you can specify is 0. This is defined by the constant configLIBRARY_KERNEL_INTERRUPT_PRIORITY in FreeRTOSConfig.h.
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. The interrupt driven UART demo in the STM32/IAR demo can be used as an example. See the file FreeRTOS\Demo\CORTEX_STM32F103_IAR\serial\serial.c for a full example, but note that this example is intended to demonstrate the mechanisms required only and should not be used as an example of an optimal UART driver.
Note that portEND_SWITCHING_ISR() will leave interrupts enabled.
Switching between the pre-emptive and co-operative RTOS kernelsSet the definition configUSE_PREEMPTION within FreeRTOS/Demo/CORTEX_STM32F103_Primer_GCC/FreeRTOSConfig.h to 1 to use pre-emption or 0 to use co-operative. Note that demo tasks that measure their own timing characteristics can report errors when executed using the co-operative RTOS scheduler.
Compiler optionsAs with all the ports, it is essential that the correct compiler options are used. The best way to ensure this is to base your application on the provided demo application files.
Memory allocationSource/Portable/MemMang/heap_2.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.
Video: Watch James Gosling & Richard Barry at re:Invent, Las Vegas 2017.