
This page documents a FreeRTOS ARM Cortex-M3 demo application that targets the Microsemi (formally Actel)
SmartFusion mixed signal FPGA with integrated ARM Cortex-M3 microcontroller subsystem.
FreeRTOS includes ARM Cortex-M3 ports for the IAR, Keil and GCC compilers. Demo application projects targeting the SmartFusion are provided for the IAR Embedded Workbench, Keil MDK and SoftConsole (Eclipse) IDEs. This page provides instruction on using the IAR and Keil IDEs only. A separate page provides instructions on using the SoftConsole Eclipse IDE.
The IAR and Keil projects are pre-configured to run on the A2F-EVAL-KIT SmartFusion evaluation board.
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.
An example embedded web server implementation is included. This makes use of a modified version of the tiny uIP TCP/IP stack. Code-named FreeTCPIP, the modifications to the TCP/IP stack allow a higher throughput than can be achieved with the original code. Dynamic web pages showing RTOS, TCP/IP and task run time statistics are created and served using the standard uIP CGI scripting facility.
uIP was originally written by Adam Dunkels. It is open source, but licensed separately from FreeRTOS. Users must familiarise themselves with the uIP licence, which is detailed at the top of each uIP source file.
See also the FAQ My application does not run, what could be wrong?
The Keil MDK project for the SmartFusion A2F demo is called RTOSDemo_Keil.uvproj, and is also located in the FreeRTOS/Demo/CORTEX_A2F200_IAR_and_Keil directory.
The FreeRTOS zip file download contains source code for all the FreeRTOS ports, and every demo application project. It therefore contains many more files than are required to build and run the SmartFusion demo. See the Source Code Organization section for a description of the downloaded files, and information on creating a new project.
| Build configuration | Description |
| Blinky |
This is a very simple example. It creates two tasks,
one software timer, and also uses a button interrupt.
The two tasks communicate via a queue, with the receiving task toggling an LED each time a value is received. Pressing user button SW1 generates an interrupt, the service routine for which resets a software timer before turning an LED on. The software timer has a five second period, and when the five seconds expire, the timer callback function turns the LED off again. Therefore, pressing SW1 will turn the LED on, and the LED will remain on until a full five seconds pass without the button being pressed again. The Blinky build configuration uses the main-blinky.c source file. The other two build configurations use the main-full.c source file.
|
| Full |
This is a comprehensive demo that creates lots of tasks,
queues, semaphores (of various types) and software timers.
The Full build configuration creates the same tasks and timers that are created by the Blinky build configuration. In addition to these, the Full build configuration also creates a lot of tasks from the set of standard demo tasks. The standard demo tasks don't perform any particular function. Their purpose is firstly to test the FreeRTOS port, and secondly to provide examples of how to use the FreeRTOS API functions. The Full build configuration creates yet more tasks that are neither part of the Blinky configuration or the set of standard demo tasks. These additional tasks are described briefly below this table.
|
| Full_with_optimisation |
The functionality of the Full_with_optimisation build configuration
is identical to that of the Full build configuration. The compiler
optimisation setting is the only difference between the two.
|
Tasks and timers that are created by both Full build configurations, that are
not part of either the Blinky demo, or the standard demo tasks, include:
Each time the check timer expires, its associated callback function queries the status of all the running standard demo tasks. If any queried status is returned as 'failed', then the period of the Check timer is shortened to 500ms from its original setting of 3 seconds.
The check timer callback toggles LED D8 each time it executes. Therefore, if LED D8 toggles every three seconds, then no errors have been discovered. If LED D8 toggles every 500ms, then at least one standard demo task has reported an error. The name of the standard demo task that reported the error can be viewed using the embedded web server - it is displayed at the bottom of the "task stats" web page, under the task stats table.
All TCP/IP related processing is contained in the uIP task. The Flash and RAM footprint of the TCP/IP stack is extremely small compared to other embedded TCP/IP implementations.
The OLED task scrolls a message across both rows of the OLED.
The IP addresses used by the web server running on the SmartFusion device, and the web browser used to connect to the web server, must be compatible with each other. To ensure this is the case, make the first three octets of both IP addresses the same. For example, if the web browser computer uses IP address 10.10.10.1, then the SmartFusion device can be given any IP address in the range 10.10.10.2 to 10.10.10.254 - other than any IP addresses that are already present on the same network.
The MAC address assigned to the SmartFusion device must be unique on the network to which the device is being connected.
If you are using the Keil MDK, then connect a U-Link debugger interface to the connector labelled "RVI-HEADER".
The "IO" page also displays the raw reading of the analogue input port connected to the potentiometer marked 50K_POT (mounted next to the OLED on the development board).

The RTOS stats page served by the SmartFusion web server
showing status information on each task in the system.
The run time stats page served by the SmartFusion web
server showing the processor utilisation of each task.

The served IO page
The IO page provides a simple interface to permit two LEDs to be turned on and off from a web browser. It also displays the current raw analogue input reading from the 50K potentiometer that is located next to the OLED on the evaluation board. Changes are sent to the target board whenever the "Update IO" button is clicked. Values displayed on the IO page are updated each time the "Update IO" button is clicked, or the served web page is refreshed.
Other served pages include TCP/IP statistics, and a large JPG image. All the web pages are included in the downloaded binary image - which can make the binary image appear to be quite large (the jpg file by itself is in excess of 36K).
This sets the frequency of the RTOS tick interrupt. The supplied value of 1000Hz is useful for testing the RTOS kernel functionality but is faster than most applications require. Lowering this value will improve efficiency.
See the RTOS kernel configuration documentation for full information on these configuration constants.
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 A2F the lowest priority you can specify 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, and none as sub priority bits.
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 portEND_SWITCHING_ISR() will leave interrupts enabled.
This demo project provides examples of FreeRTOS interrupt service routines - namely GPIO8_IRQHandler() defined in main-full.c and main-blinky.c, and the Ethernet MAC interrupt handler.
Only FreeRTOS API functions that end in "FromISR" can be called from an interrupt service routine - and then only if the priority of the interrupt is less than or equal to that set by the configMAX_SYSCALL_INTERRUPT_PRIORITY configuration constant.