Homepage  

STMicroelectronics STM32F103 Cortex M3 Demo
[RTOS Ports]




This page describes the FreeRTOS.org demo application for the STMicroelectronics STM32 Cortex-M3 microcontroller. The demo uses the IAR Embedded Workbench development tools for ARM, and is preconfigured to run on the STM32 evaluation board from ST (instructions are provided should you wish to use an alternative development board). The evaluation board is fitted with an STM32F103VB microcontroller that contains 128KBytes of on board flash and 20KBytes of on board RAM. The STM32F103VB also includes both USB and CANbus peripherals.

Note: The V4.3.0 version of the IAR Cortex M3 port introduced the 'configKERNEL_INTERRUPT_PRIORITY' configuration parameter. This parameter permits the interrupt priority used by the kernel to be configured such that the kernel activity will never delay a higher priority interrupt. See the Configuration and Usage section of this page for more information.

From FreeRTOS.org V4.7.1 all IAR projects for ARM devices are saved using the IAR Embedded Workbench V5.x format and will not open from V4.x versions. FreeRTOS.org V4.7.0 and earlier are still available from SourceForge and can be used with Embedded Workbench V4.x.

Upgrading to FreeRTOS.org V4.8.0: Prior to V4.8.0 the FreeRTOS.org 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.org download have already been updated so these can be used as an example.


IMPORTANT! Notes on using the STM32 Cortex-M3 Demo

Please read all the following points before using this RTOS port.

  1. Source Code Organisation
  2. The Demo Application
  3. RTOS Configuration and Usage Details
See also the FAQ My application does not run, what could be wrong?

Source Code Organisation

The FreeRTOS.org download includes the source code for all the FreeRTOS.org 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 IAR workspace file for the STM32F103 demo is called RTOSDemo.eww and is located in the FreeRTOS/Demo/CORTEX_STM32F103_IAR directory.


The Demo Application

Demo application hardware setup

The demo application includes an interrupt driven UART test where one task transmits characters that are then received by another task. For correct operation of this functionality a loopback connector must be fitted to the UART00 connector of the STM32 evaluation board (pins 2 and 3 must be connected together on the 9Way connector).

The demo application uses the LEDs and display built onto the prototyping board so no other hardware setup is required.

A J-Link USB JTAG interface is used to interface the host PC with the target.


Building and running the demo application

  1. Open the FreeRTOS/Demo/CORTEX_STM32F103_IAR/RTOSDemo.eww project from within the Embedded Workbench IDE.

  2. Select 'Rebuild All' from the IDE 'Project' menu. The project should build with no errors or warnings.

  3. Select 'Debug' from the IDE 'Project' menu. The microcontroller flash memory will be programmed with the newly built binary and the debugger will break on the entry to main().

The project includes a bitmap that is built into the binary. This increases the binary size and at some optimisation levels will take the build size above the 32K limit of the Embedded Workbench Kickstart edition. If this becomes an issue then the code size can be reduced by excluding the bitmap from the build (by removing the pcBitmap array from lcd_message.h, and commenting out the call to LCD_DrawMonoPict() within the same file).


Functionality

The demo application creates 24 persistent tasks, and periodically dynamically creates and destroys another 4. 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 Configuration and Usage Details


RTOS Port specific configuration

Configuration items specific to these demos are contained in FreeRTOS/Demo/CORTEX_STM32F103_IAR/FreeRTOSConfig.h. The constants defined in this file can be edited to suit your application. In particular -

Each port #defines 'portBASE_TYPE' to equal the most efficient data type for that processor. This port defines portBASE_TYPE to be of type long.

Note that vPortEndScheduler() has not been implemented.


Interrupt service routines

Unlike 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.


Switching between the pre-emptive and co-operative real time kernels

Set the definition configUSE_PREEMPTION within FreeRTOS/Demo/CORTEX_STM32F103_IAR/FreeRTOSConfig.h to 1 to use pre-emption or 0 to use co-operative.


Compiler options

As 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 allocation

Source/Portable/MemMang/heap_2.c is included in the ARM Cortex-M3 demo application project to provide the memory allocation required by the real time kernel. Please refer to the Memory Management section of the API documentation for full information.




Copyright (C) 2003 - 2008 Richard Barry
Any and all data, files, source code, html content and documentation included in the FreeRTOS.org distribution or available on this site are the exclusive property of Richard Barry. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Richard Barry.