The port was developed using the DK-LM3S316 development kit.
The LM3S316 is a low cost, low pin count device. It has 4KBytes of RAM and 16KBytes of ROM on chip. The demo application code size has been deliberately limited to ensure it builds using the code size limited KickStart version of the IAR tools.
The IAR ARM Cortex-M3 demo relies on a driver library file which is licensed separately from FreeRTOS.org. A full copy of the license applicable to this library is contained in the EULA.txt file located in the Demo/CORTEX_LM3S316_IAR/hw_include directory within the FreeRTOS download.
There are currently four FreeRTOS ports for Luminary Micro Stellaris ARM Cortex-M3 based microcontrollers - one that uses the Sourcery G++ (GCC) tools, one that uses the ARM Keil tools, one for Rowley CrossWorks, and the port presented on this page which uses the IAR Embedded Workbench tool chain.
Note: If this project fails to build using the IAR tools then it is likely the version of IAR Embedded Workbench being used is too old. If this is the case, then it is also likely that the project file has been (silently) corrupted and will need to be restored to its original state before it can be built even with an updated IAR version.
IMPORTANT! Notes on using the ARM Cortex-M3 IAR portPlease read all the following points before using this RTOS port.
My application does not run, what could be wrong?
Source Code OrganizationThe FreeRTOS download contains the source code for all the FreeRTOS ports so contains many more files than used by 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 for the Luminary Micro port is located in the FreeRTOS/Demo/CORTEX_LM3S316_IAR directory and is called RTOSDemo.eww.
The Demo ApplicationThe FreeRTOS source code download includes a preconfigured demo applications for the IAR port. This demonstrates both fully preemptive tasks and co-routines - with 8 co-routines and 5 tasks being created (including the idle task).
Demo application hardware setupMost of the DK-LM3S316 jumpers can remain in their default positions. For the ADC to correctly read the light sensor ensure jumper 0 is also in position on the ADC connector JP2.
The demo application includes an interrupt driven UART test where a co-routine transmits characters that are then received by a task. For correct operation of this functionality a loopback connector must be fitted to the SER0 connector of the DK-LM3S316 target board (pins 2 and 3 must be connected together on the 9Way connector).
The demo application uses the LEDs built into the prototyping board so no other hardware setup is required.
A J-Link JTAG interface is used to interface the host PC with the target.
FunctionalitySee the comments at the top of Demo/CORTEX_LM3S316_IAR/main.c for a detailed explanation of the demo functionality.
When executing correctly the demo application will behave as follows:
Building and executing the demo application
To build the application simply open RTOSDemo.eww from within the Embedded Workbench IDE, then select "Rebuild all" from the "Project" menu.
To download then execute the demo:
RTOS port specific configurationConfiguration items specific to these demos are contained in FreeRTOS/Demo/CORTEX_LM3S316_IAR/FreeRTOSConfig.h. The constants defined in this file can be edited to suit your application. In particular -
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. Use the supplied examples as a reference.
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 routinesThe interrupt vector table is contained within FreeRTOS/Demo/CORTEX_LM3S316_IAR/hw_include/startup.c and can be populated as required. In the demo application the vector table remains in flash.
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. This mechanism is demonstrated by the UART ISR called vUART_ISR() and defined within commtest.c.
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_LM3S316_IAR/FreeRTOSConfig.h to 1 to use pre-emption or 0 to use co-operative. The demo application will only execute correctly with configUSE_PREEMPTION set to 0 if configIDLE_SHOULD_YIELD is set to 1.
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_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.
Serial port driverIt should also be noted that the serial drivers are written to test some of the real time kernel features - and they are not intended to represent an optimized solution.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
Video: Watch James Gosling & Richard Barry at re:Invent, Las Vegas 2017.