Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Microsemi (formally Actel) SmartFusion A2F200M3F Demo
Using IAR and Keil - Including an embedded web server with CGI scripting
[Embedded Ethernet Examples]


Microsemi SmartFusion A2F200M3 Evaluation Board A2F-EVAL-KIT
SmartFusion A2F-EVAL-KIT Evaluation Kit



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.


IMPORTANT! Notes on using the FreeRTOS IAR and Keil SmartFusion example projects

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 Embedded Workbench workspace for the SmartFusion A2F demo is called RTOSDemo_IAR.eww, and is located in the FreeRTOS/Demo/CORTEX_A2F200_IAR_and_Keil directory.

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.


The SmartFusion A2F Demo Application

Functionality

The IAR and Keil projects each contain three build configurations:

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:

  • A "Check" software timer and callback

    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.

  • uIP task

    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.

  • OLED task

    The OLED task scrolls a message across both rows of the OLED.


Web server configuration

The demo application includes an embedded web server. The IP address used by the web server is fixed, and set set by the constants configIP_ADDR0 to configIP_ADDR3. The definition of these constants can be found near the bottom of the FreeRTOSConfig.h header file, which is itself located in the same directory as the IAR and Keil demo project files. Constants that define the MAC address, and the NET mask, are located in the same header file.

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.


Hardware set up

This section provides instructions on the hardware set up required to program an application into the ARM Cortex-M3 flash memory. It is assumed that the FPGA fabric and ACE are already configured correctly, which will be the case if the configuration has not been changed from that shipped. However, if the FPGA fabric or ACE configuration has been altered from that shipped, and you find the demo application does not execute correctly, then it is recommended to restore the FPGA fabric and ACE configuration using the .pdb file supplied with the A2F-EVAL-KIT.
  1. Ensure jumpers JP7 and JP10 are set to the RVI and M3 positions respectively.

  2. If you are using the IAR Embedded Workbench, then connect a J-Link debugger interface to the connector labelled "RVI-HEADER".

    If you are using the Keil MDK, then connect a U-Link debugger interface to the connector labelled "RVI-HEADER".

  3. Use an Ethernet cable to connect the A2F-EVAL-KIT hardware to a computer running a standard web browser. This needs to be done either directly, by using a crossover (point to point) Ethernet cable, or through a hub/switch, using a standard Ethernet cable. Only the direct connection option was tested during development of the demo, but both methods should work.

  4. Power the A2F-EVAL-KIT using the USB connector J14.


Building and executing the demo application, using the IAR tools

  1. Open the RTOSDemo_IAR.eww Embedded Workbench workspace from within the Embedded Workbench IDE.

  2. If you wish to use the embedded web server, then select either the Full or the Full_with_optimisation build configuration. If you want to start with a very simple example, then select the Blinky build configuration.

  3. Select "Build All" from the Embedded Workbench "Project" menu - the demo application should build without errors.

  4. When the build completes, select "Download and Debug" from the Embedded Workbench "Project" menu (or just press CTRL+D) to program the microcontroller flash memory, and start a debug session. The application will start to run, and then break on entry to the main() function.


Building and executing the demo application using Keil tools

  1. Open the RTOSDemo_Keil.uvproj project from within the Keil IDE.

  2. If you wish to use the embedded web server, then select either the Full or the Full_with_optimisation build configuration. If you want to start with a very simple example, then select the Blinky build configuration. (Build configurations are called 'targets' in the MDK environment).

  3. Select "Build Target" from the IDE's "Project" menu - the demo application should build without errors.

  4. When the build complete, select "Start/Stop Debug Session" from the IDE's "Debug" menu (or just press CTRL+F5) to program the microcontroller flash memory, and start a debug session.


Demo functionality

When executing correctly, the demo application will behave as follows:

  • The LEDs marked D1, D2 and D3 are under the control of the standard demo 'flash' tasks. Each will toggle at a fixed frequency, with LED D1 using the fastest frequency, and LED D3 using the slowest frequency.

  • The LEDs marked D4 and D5 can be turned on an off interactively using a web browser. The facility to do this is provided on the "IO" page that is served by the embedded web server.

    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 LED marked D6 is under the control of queue receive task. It will toggle each time the queue receive task receives a value, which will be every 200ms.

  • The LED marked D7 will turn on when button SW1 is pressed (assuming it was not already on). Five seconds after SW1 was last pressed, the LED software timer will turn LED D7 off again.

  • The LED marked D8 is under the control of the 'check' software timer. D8 will toggle every 3 seconds if no errors have been reported, or every 500ms if a standard demo task has ever reported an error.

  • "www.FreeRTOS.org" will scroll across both lines of the OLED - with the text on the bottom line leading that on the top by five characters.

  • The integrated web server will serve the web pages described below, to a standard web browser. To connect to the target:

    1. Open a web browser on the connected computer.
    2. Type "HTTP://" followed by the target IP address into the browsers address bar.


      Entering the IP address into the web browser
      (obviously use the correct IP address for your system)


Served web Pages

The top of each served page includes a menu with links to every other page.

FreeRTOS SmartFusion web server showing RTOS statistics

The RTOS stats page served by the SmartFusion web server
showing status information on each task in the system.


FreeRTOS SmartFusion web server showing RTOS run time information

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



RTOS Configuration and Usage Details


Cortex-M3 FreeRTOS port specific configuration

Configuration items specific to this demo are contained in FreeRTOS/Demo/CORTEX_A2F200_IAR_and_Keil/FreeRTOSConfig.h. The constants defined in this file can be edited to suit your application. In particular -
  • configTICK_RATE_HZ

    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.

  • configKERNEL_INTERRUPT_PRIORITY and configMAX_SYSCALL_INTERRUPT_PRIORITY

    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.


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 interrupt service routine.

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.


Resources used by FreeRTOS

FreeRTOS requires exclusive use of the SysTick and PendSV interrupts. SVC number #0 is also used.


Switching between the pre-emptive and co-operative RTOS kernels

Set the definition configUSE_PREEMPTION within RTOSDemo/FreeRTOSConfig.h to 1 to use pre-emption or 0 to use co-operative. The full demo application may not execute correctly when the co-operative RTOS scheduler is selected.


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 SmartFusion A2F 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.


Miscellaneous

Note that vPortEndScheduler() has not been implemented.





[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner