AT91SAM3U Cortex M3 FreeRTOS demo
Using the IAR compiler
[RTOS Ports]



The demo application presented on this page is pre-configured to execute on the official SAM3U-EK evaluation kit from Atmel. The demo uses the FreeRTOS IAR Cortex-M3 port and can be compiled and debugged directly from the IAR Embedded Workbench for ARM.

The FreeRTOS Cortex M3 port includes a full interrupt nesting model. Interrupt priorities must be set in accordance with the instructions on the Customisation page for correct operation.


IMPORTANT! Notes on using the Atmel 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 IAR workspace file for the SAM3 FreeRTOS demo is called RTOSDemo.eww and is located in the FreeRTOS/Demo/CORTEX_AT91SAM3U256_IAR directory.

The FreeRTOS zip file download contains the files for all the ports and demo application projects. It therefore 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 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 UART1 9 way connector on the evaluation board (pins 2 and 3 must be connected together on the 9 way connector - normally a paper clip is sufficient for this purpose).

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


Building and executing the demo application

  1. Open the FreeRTOS/Demo/CORTEX_AT91SAM3U256_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. Connect the host machine (the computer running the IAR IDE) to the target using a J-Link JTAG interface.

  4. Select 'Debug' from the IDE 'Project' menu. The microcontroller flash memory will be programmed with the demo application, and the debugger will break at the start of the main() function.


Functionality

The demo application creates 33 tasks prior to starting the scheduler. These tasks consist predominantly of the standard demo application tasks (see the demo application section for details of the individual tasks). Their only purpose is to test the kernel port and provide a demonstration of how to use the various API functions.

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 this demo are contained in FreeRTOS/Demo/CORTEX_AT91SAM3U256_IAR/FreeRTOSConfig.h. The constants defined in this file can be edited to suit your application. In particular - Attention please!: Remember that 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 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. Use the supplied examples as a reference.

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

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. An example ISR called vSerialISR() is provided in FreeRTOS/Demo/CORTEX_AT91SAM3U256_IAR/serial/serial.c, this should be used as a reference example.


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) 2010 Real Time Engineers Ltd.
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 Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd..