LPC1768 ARM Cortex-M3 IAR Demo
Including Embedded Web Server and USB Examples
[Embedded Ethernet Examples]
This page presents an IAR web server and USB demo that is pre-configured to run
on the evaluation board
that comes in the KSK-LPC1768-PL Kickstart Kit.
The evaluation board is fitted with an LPC1768
Cortex-M3 microcontroller from NXP.
The demo uses:
uIP and LPCUSB are licensed separately from FreeRTOS. Users must familiarise themselves with the uIP and
LPCUSB licenses respectively.
- The FreeRTOS IAR ARM Cortex-M3 port.
- The IAR Embedded Workbench V5.40.
- Adam Dunkels open source uIP embedded TCP/IP stack to implement a web server with CGI scripting.
- Bertrik Sikkens open source LPCUSB USB stack to implement a CDC class echo server.
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 ARM 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.
Note: If this project fails to build 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.
IMPORTANT! Notes on using the NXP ARM Cortex-M3 Web Server Demo
Please read all the following points before using this RTOS port.
See also the FAQ My application does not run, what could be wrong?
- Source Code Organisation
- The Demo Application
- RTOS Configuration and Usage Details
Source Code Organisation
The IAR Embedded Workbench workspace for the LPC1768 demo is called RTOSDemo.eww and can be found in the FreeRTOS/Demo/CORTEX_LPC1768_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
web server configuration
Connect the evaluation board to a computer running a web browser either directly using a point to point (crossover)
cable, or via a 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_LPC1768_IAR/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 evaluation 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
- Open FreeRTOS/Demo/CORTEX_LPC1768_IAR from within the Embedded Workbench IDE.
- Kickstart versions of Embedded Workbench can only be used with compiled binary images of 32K bytes and under - it is necessary to set the compiler optimisation to 'medium' prior to compilation if the
Kickstart edition is being used.
- Connect the evaluation board to the host computer using a J-Link USB JTAG interface.
- Select "Download and Debug" from the "Project" menu - the demo application should build with no errors or warnings before being
programmed into the LPC1768 Flash memory. The debugger will break at the start of main().
The demo application creates 34 tasks before starting the RTOS scheduler. The tasks consist
primarily of the standard demo tasks (see the demo application
section for details of the individual tasks). They exist to demonstrate how the FreeRTOS API can be used and test the
FreeRTOS port only, and have no other useful purpose.
The following tasks and tests are created in addition to the standard demo tasks:
- Check function - called from the tick hook
This only executes every five seconds. Its main function is to check that all the
standard demo tasks are still operational. The check function maintains a status string that
can be viewed on the "Task Stats" page served by the uIP TCP/IP web server.
- uIP task
This is the task that handles the uIP stack. All TCP/IP processing is performed in this task.
- USB task
This is the task that handles the USB stack. The USB device will enumerate as a CDC device. The USB task simply echoes received characters with
an offset which by default is one. Therefore if 'A' is received 'B' will be echoed back. If 'x' is received 'y' will be echoed back, etc.
When executing correctly the demo application will behave as follows:
Note that the LCD is not used because the LCD driver is only permitted to be used with the Keil compiler.
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 an LED. The check box permits the state of
the user LED 2 to be both set and queried.
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 port specific configuration
Configuration items specific to these demos are contained in FreeRTOS/Demo/CORTEX_LPC1768_IAR/FreeRTOSConfig.h. The
constants defined in this file can be edited to suit your application. In particular -
Attention please!: Remember that ARM 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.
This sets the frequency of the RTOS tick. 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.
The lowest priority on a ARM Cortex-M3 core is in fact 255 - however different ARM 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 'BaseType_t' to equal the most efficient data type for that processor. This port defines
BaseType_t 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
vEMAC_ISR() is provided in FreeRTOS/Demo/CORTEX_LPC1768_IAR/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 RTOS kernels
Set the definition configUSE_PREEMPTION within FreeRTOS/Demo/CORTEX_LPC1768_IAR/FreeRTOSConfig.h to 1 to use pre-emption or 0
to use co-operative.
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.
Source/Portable/MemMang/heap_2.c is included in the ARM Cortex-M3 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
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.