![]() Studio Cadrage |
From FreeRTOS.org V4.7.1 all IAR projects for ARM devices are saved using the IAR Embedded Workbench V5.x format and will not open from V4.x versions. FreeRTOS.org V4.7.0 and earlier are still available from SourceForge and can be used with Embedded Workbench V4.x.
This page describes one of the FreeRTOS SAM7X embedded Ethernet TCP/IP sample applications. The demo uses the FreeRTOS IAR SAM7 ARM port and Adam Dunkels open source uIP stack to create an embedded WEB server on an AT91SAM7X-EK development board (instructions are provided should you wish to use an alternative development board). An alternative project is also available to demonstrate the use of the more feature rich lwIP TCP/IP stack using the GCC compiler.
Click to see live pages served from an AT91SAM7X256 using this demo application.
[A non standard port number is used which may be blocked by some proxy servers and firewalls.]
This demo -
As downloaded this demo application does not demonstrate the use of co-routines. See the co-routine documentation page for information on how co-routine functionality can be quickly added to this demonstration.
See also the FAQ My application does not run, what could be wrong?
This SAM7X WEB Server demo uses the standard FreeRTOS IAR SAM7 port. The uIP IAR demo project workspace rtosdemo.eww can be found in the Demo/uIP_Demo_IAR_ARM7 directory and should be opened from within the Embedded Workbench IDE.
The Demo/uIP_Demo_IAR_ARM7/SrcIAR and the Demo/uIP_Demo_IAR_ARM7/resource directories contain support files for the Atmel libraries and build environment.
Adam Dunkels uIP code is located in the Demo/uIP_Demo_IAR_ARM7/uIP directory. The HTML files used with the demo can be found in the Demo/uIP_Demo_IAR_ARM7/uIP/fs directory.
Finally the Demo/uIP_Demo_IAR_ARM7/EMAC directory contains the EMAC driver.
The IP address used by the demo is set by the constants UIP_IPADDR0 to UIP_IPADDR3 within the file Demo/uIP_Demo_IAR_ARM7/uIP/uipopts.h. The IP addresses used by the WEB browser computer and the prototyping 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 prototyping 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).
The MAC address used by the demo is set by the constants UIP_ETHADDR0 to UIP_ETHADDR5, also within uipopts.h. You must ensure that the configured MAC address is unique on the network to which the prototyping board is being connected.
Demo/uIP_Demo_IAR_ARM7/EMAC/SAM7_EMAC.c contains the definition USE_RMII_INTERFACE. This must be set appropriately for your hardware. Setting USE_RMII_INTERFACE to 1 configures the MAC to operate in RMII mode. Setting USE_RMII_INTERFACE to 0 configures the MAC to operate in MII mode.
The demo application uses the LEDs built into the prototyping board so no other hardware setup is required.
Simply open the rtosdemo.eww workspace file from within the IAR Embedded Workbench IDE, ensure flash debug is the selected
configuration (see picture below), then select 'Built Target' from the IDE 'Project' menu.
When executing correctly the demo application will behave as follows:

LED DS4 is under control of the 'Check' task. Every three seconds the 'Check' task examines all the tasks in the system to ensure they are executing without error. It then toggles LED DS4. If LED DS4 is toggling every three seconds then no errors have ever been detected. The toggle rate increasing to 500ms indicates that the 'Check' task has discovered at least one error.
The RTOS CGI file generates a table containing information on each task executing within the demo. This table is interesting for demonstration purposes, but as it is necessary to leave interrupts disabled for an extended period during its creation it is not recommended for use in applications with strict real time requirements.
The EMAC DMA operation makes the interaction between the EMAC peripheral and the WEB server task very simple. The interaction is further simplified by the single buffer memory management of uIP. The lwIP stack implements a more flexible (complex) memory management scheme, therefore the lwIP demo application contains a more comprehensive EMAC driver.
Data received by the EMAC is buffered under control of the DMA. When a buffer is available for processing an EMAC interrupt is generated. All the interrupt service routine does is signal to the uIP task via a semaphore that data is available for processing. The semaphore immediately unblocks the uIP task, which processes the data and if necessary generates a response.
The uIP task blocks on the semaphore with a timeout. Therefore should no data become available for processing, the uIP task will periodically unblock to carry out the periodic processing required by the TCP/IP stack.
The number of receive buffers available to the EMAC is set by the constant NB_RX_BUFFERS within the file Demo/uIP_Demo_IAR_ARM7/SrcIAR/emac.h. Each receive buffer is 128 bytes.
The number of transmit buffers available to the EMAC is set by the constant NB_TX_BUFFERS also within emac.h. The size of each transmit buffer is equal to the uIP buffer size.
The driver included in the download uses the EMAC in its most basic configuration.
NOTE! : The processor MUST be in supervisor mode when the scheduler is started (vTaskStartScheduler is called). The demo applications included in the FreeRTOS.org download switch to supervisor mode prior to main being called. If you are not using one of these demo application projects then ensure Supervisor mode is entered before calling vTaskStartScheduler().