STM32 Connectivity Line Cortex M3 demo
Including a uIP Embedded Web Server Example
[Embedded Ethernet Examples]



The demo presented on this page uses:

uIP is licensed separately from FreeRTOS. Users must familiarise themselves with the uIP license.

FreeRTOS has made some modifications to the uIP stack since this demo was created. See the Embedded Ethernet Examples List page for more information.

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 ST Cortex-M3 Web Server 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 CrossWorks workspace for the STM32F107 demo is located in the FreeRTOS/Demo/CORTEX_STM32F107_GCC_Rowley 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

web server configuration

Ensure that jumper JP4 is set so that JP4 pins 1 and 2 are shorted - this routes the output of the external 25MHz crystal to the PHY. Jumpers JP3, JP11, JP12 and JP13 need to be shorting pins 2 and 3, which should be the default setting.

Connect the STM3210C evaluation board to a computer running a web browser either directly using a point to point (crossover) cable, or via an Ethernet switch using a standard Ethernet cable.

The IP address used by the demo is set by the constants configIP_ADDR0 to configIP_ADDR3 within the file FreeRTOS/Demo/CORTEX_STM32F107_GCC_Rowley/FreeRTOSConfig.h. The MAC address and net mask are configured within the same header file.

The IP addresses used by the web browser computer and the STM32 development board must be compatible. This can be ensured by making the first three octets of both IP addresses identical. For example, if the web browser computer uses IP address 192.168.100.1, then the development board can be given any address in the range 192.168.100.2 to 192.168.100.254 (barring any addresses already present on the network).


Building and executing the demo application

  1. Open the FreeRTOS/Demo/CORTEX_STM32F107_GCC_Rowley/RTOSDemo.hzp solution from within the CrossStudio IDE.
  2. Select the appropriate build configuration - either "THUMB Flash Debug" if you wish to debug the application, or "THUMB Flash Release" if you wish to run the application stand alone (without the debugger). Note that the "Thumb Flash Debug" configuration can only be used in combination with the debugger - it can not be used to execute the demo simply by resetting the board.



    Selecting the build configuration


  3. Select "Build RTOSDemo" from the "Build" menu - the solution should build with no errors or warnings.
  4. Connect your chosen JTAG interface between the host computer and the target hardware (the project was developed using a J-Link), apply power to the target, then connect to the target using the appropriate item from the IDE "Target" menu.
  5. Select "Start Debugging" from the "Debug" menu. The microcontroller Flash memory will be programmed and the debugger will break at main.


The ST peripheral library

Please note that the peripheral library utilised by the demo application is neither re-entrant nor event driven.

During its initialisation, the demo application accesses IO port configuration from within more than one task. This raises the possibility of problems related to re-entrancy (or lack of it). No attempt is made to guard against this. If this proves problematic then place the initialisation library calls inside critical sections.

The LCD driver uses a polled SPI interface. Currently the LCD gatekeeper task is configured to execute at a medium priority - resulting in lower priority tasks not getting any processing time while the SPI interface is being polled. The task can be configured to execute at the lowest priority, but this results in visibly slower LCD updates. A much more efficient solution would be to re-implement the driver to make use of the DMA and be event driven.


Functionality

The demo application creates 30 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:


Served Web Pages

The top of each served page includes a menu containing a link to every other page.


The served RTOS stats page showing status information on each task in the system.

The served run time stats page showing the processor utilisation of each task.


The served IO page

The IO page provides a simple interface that permits data to be sent to LED 4 and LCD on the development board.

The check box permits the state of LED 4 to be set and queried. The text box can be used to write a message to the LCD, but does not query the text currently being display. Changes are sent to the target hardware by clicking the "Update IO" button.

The TCP Stats and Connections pages display run time networking information.



RTOS Configuration and Usage Details


RTOS Port specific configuration

Configuration items specific to these demos are contained in FreeRTOS/Demo/CORTEX_STM32F107_GCC_Rowley/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 interrupt service routine called vMAC_ISR() is provided in FreeRTOS/Demo/CORTEX_STM32F107_GCC_Rowley/webserver/emac.c. This should be used as a reference example.

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_STM32F107_GCC_Rowley/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) 2004-2010 Richard Barry. Copyright (C) 2010-2012 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOS 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..