This page describes two demo applications that use FreeRTOS-Plus-IO and FreeRTOS-Plus-CLI
on the LPCXpresso Base Board BSP.
The second demo integrates lwIP and FatFS to
provide a Telnet "like" command line interface to files stored on an SD card.
These demos are very comprehensive; simpler code snippets can be found on the
quick examples page, and on
most of the FreeRTOS-Plus-IO and FreeRTOS-Plus-CLI documentation pages.
These demos use the standard FreeRTOS Cortex-M3 GCC port. It is important
that users wishing to use this port without FreeRTOS-Plus-IO first consult
the port documentation to gain an understanding of the interrupt configuration
settings required to use the FreeRTOS interrupt nesting model. The
FAQ that documents the most common mistakes made
when using a multitasking kernel on a Cortex-M device is a good place to start.
Six commands are registered with
FreeRTOS-Plus-CLI. These are run-time-stats, task-stats,
echo-parameters, echo-3-parameters, create-task and
delete-task.
Enter "run-time-stats" in the command console
to see the amount of time each task has spent
in the Running state since it was created.
Enter "task-stats" in the command console
to see a snapshot of task state information - including
stack high water mark data.
Enter "echo-parameters" followed by one or more command line
parameters to see the (variable) number of parameters echoed
back. This command demonstrates defining and implementing
commands that can take any number of parameters.
Enter "echo-3-parameters" followed by three command line
parameters to see the (fixed) number of parameters echoed
back. This command demonstrated defining and implementing
commands that expect an exact number of parameters.
Enter "create-task" followed by a single numeric parameter
to create a task that accepts the entered number as its task
parameter. The task will print (to the command console) the
parameter value when it starts executing. The "task-stats"
command can be used to see the additional task running.
Enter "delete-task" to delete the task that was created using
the "create-task" command.
As delivered, UART3 is set to
115200 baud, no start bits, 8 data bits and 1 stop bit.
On the base board, UART3 is routed via a UART
to USB converter, to the micro USB connector marked X3.
The terminal
program used to connect to the target must be configured
to send line ends with line feeds. Release 1 of the featured
demo required the terminal program to echo typed characters
locally, release 2 does not.
Display Driver
FreeRTOS-Plus-IO is used to implement an OLED display driver.
The I2C2 peripheral is used for output, so the base board
jumpers must be set to configured the OLED for I2C operation.
The example demonstrates the I2C port being used
in both the polled
and interrupt driven zero copy
transfer modes.
Serial EEPROM Interface
FreeRTOS-Plus-IO is used to write to, then read back from,
an EEPROM that is connected to the I2C2 peripheral.
The example demonstrates the I2C port being used
in the polled
and interrupt driven zero copy
transfer modes to write to the EEPROM, and the polled and
interrupt driven circular buffer
transfer modes to read back from the EEPROM.
7-Segment Display
This time FreeRTOS-Plus-IO is used with an SSP peripheral that is
configured in SPI mode. The
polled transfer mode
is used to periodically write an incrementing number to a 7-segment display.
GPIO
FreeRTOS software timers are used to periodically toggle
the multi-coloured LEDs.
Jumpers must be set correctly! Relevant jumper settings
are pictured below. Note the settings in the first
picture are different to those shown for Demo 1!
If you are using the ISP bootloader, so have J62 set, then
you must also remove J54 (may only be applicable to Rev B
base boards).
In this demo, FreeRTOS-Plus-CLI, FreeRTOS-Plus-IO,
lwIP
and FatFS
are used to create the following examples. NOTE: An SD card
must be inserted for this demo to run!.
SD Card MMC Driver for FAT File System
A FAT compatible file file system is hosted on
an SD card that uses an SPI interface. The FreeRTOS-Plus-IO
API is used with an SSP peripheral to provide
the necessary input and output. FatFS is used
to provide the file system functionality.
The example demonstrates files being written to
and read from the SD card using all the available
FreeRTOS-Plus-IO transfer modes.
The file name is used to indicate the mode being
used when the file was created, and 20 files are
created using each mode.
The files can be listed and manipulated
using FreeRTOS-Plus-CLI - see below.
Telnet "like" Command Console
FreeRTOS-Plus-CLI creates a command
console on the standard telnet TCP/IP port (port 23).
The lwIP sockets API is used to provide the
TCP/IP implementation.
The command console uses the telnet
port number, and can be accessed using a standard
telnet client, but it is not a full
telnet server.
The example uses a static IP address that is
configured using the configIP_ADDR0-configIP_ADDR3
constants defined in FreeRTOSConfig.h.
Five commands are registered with
FreeRTOS-Plus-CLI. These are dir, copy and del to
manipulate the file system (see above), and
run-time-stats and task-stats to view FreeRTOS
task information.
Enter "dir" in the command console to see a
file system directory listing.
Enter "del <filename>" in the command console
to delete a file from the SD card.
Enter "copy <source_file> <destination_file>"
in the command console to copy a file.
Enter "run-time-stats" in the command console
to see the amount of time each task has spent
in the Running state since it was created.
Enter "task-stats" in the command console
to see a snapshot of task state information - including
stack high water mark data.
The terminal
program used to connect to the target must be configured
to send line ends with line feeds and echo typed characters
locally.
A web Server
The lwIP raw API is used to create a simple web
server. The web server uses server side
includes (SSI) to display task state and
run time information.
GPIO
FreeRTOS software timers are used to periodically toggle
the multi-coloured LEDs.
Both demos are configured to run on the
LPCXpresso LPC1769 CPU board
fitted to an LPCXpresso base board. The LPCXpresso IDE is used to build,
flash, and debug the application.
Start the LPCXpresso IDE.
Create a new workspace, or select an existing workspace when prompted.
Select "Import" from the IDE "File" menu, then select "Existing Projects Into Workspace", as
shown below, before clicking "Next".
Selecting "Existing Projects Into Workspace" in the Import dialogue box
Click the "Select Archive File" radio button, ensure the
"Copy projects into workspace" check box is checked, then
navigate to and select the zip file downloaded in step one.
The dialogue box will list a number of project files. Ensure
all the projects are selected, then click finish.
The import process will attempt to create some
files more than once - resulting in a dialogue box being
displayed that warns of the potential for files to be overwritten.
When this happens, simply select the "No to all" option.
Ensure each project is checked as all the projects
are required to build the application.
The imported projects will appear in the LPCXpresso IDE's project
explorer window. To build demo 1, select "FreeRTOS-Plus-Demo-1" in the project
explorer, then select "Build Project" from the IDE
"Project" menu. Building FreeRTOS-Plus-Demo-1 will result in
all its dependent projects being built too.
Likewise, to build project 2, select "FreeRTOS-Plus-Demo-2"
in the project window before selecting "Build Project" from
the IDE "Project" menu.
Selecting "Build Project" with FreeRTOS-Plus-Demo-1 selecting in the project explorer
Connect a USB cable between the USB socket on the LPCXpresso
base board and the host computer. Only after this first connection
has been made, connect a second USB cable
between the debug USB socket on the LPCXpresso CPU board and
the host computer. Note: This sequence seems to be
important in order for a debug session to be started successfully.
Each demo requires slightly different jumper settings. The
jumper settings are pictured next to the demo descriptions
above. Ensure the jumpers are set correctly for the selected demo,
and, if Demo 2 is selected, also ensure an SD card has been
inserted into the relevant connector on the base board (the demo will
not run without it!).
Click the debug speed button in the LPCXpresso IDE to start
a debug session.
The location of the debug speed button in the LPCXpresso IDE
The workspace contains the following five projects:
Project
Description
CMSISv2p00_LPC17xx
This is the standard CMSIS library provided by NXP for the LPC17xx family
of microcontrollers.
lpc17xx.cmsis.driver.library
This is the peripheral driver library provided by NXP for the
LPC17xx family of microcontrollers. It is used, in part, by
the FreeRTOS-Plus-IO LPC17xx port layer. It contains very few modifications
from the code distributed by NXP themselves.
FreeRTOS-Products
This contains the FreeRTOS real time kernel, FreeRTOS-Plus-CLI and FreeRTOS-Plus-IO
code, organised into three separate respective directories. Note that this project is
not actually built directly - the source code it contains is just referenced by the
two demo application projects. The demo projects reference the files using
workspace relative paths - which is why the projects will only build when
they are located in the workspace directory.
FreeRTOS-Plus-Demo-1
This project contains the demo 1 application code itself - which in turn
uses source files from the FreeRTOS-Products directories.
FreeRTOS-Plus-Demo-2
This project contains the demo 2 application code itself, including the
FatFS and lwIP source files. The project also uses source files
from the FreeRTOS-Products directories.