Homepage  

TI MSP430 (MSP430F449) RTOS Port
for the CrossWorks Development Tools
[RTOS Ports]

ES449.gif

There are currently three FreeRTOS ports for the MSP430. One that uses the open source MSPGCC (GCC) compiler, and two that use the Rowley Associates CrossWorks tool suite. This page relates only to the CrossWorks ports. Thanks goes to Milos Prokic for his efforts in producing this port.

The port was developed on an ES449 development/prototyping board from SoftBaugh (instructions are provided should you wish to use an alternative development board), using the CrossWorks MSP430 compiler and a SoftBaugh FETP parallel port JTAG interface

The ES449 is a neat little MSP430F449 based prototyping board. It allows easy access to the MSP430 peripherals and includes an LCD display - great for debugging! The FETP / CrossWorks interface is seamless and fast making this a very easy to use development platform.

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.


IMPORTANT! Notes on using the CrossWorks MSP430 RTOS port

Please read all the following points before using this RTOS port.

  1. Source Code Organization
  2. The Demo Application
  3. Configuration and Usage Details
  4. Selecting the Port to Use
See also the FAQ My application does not run, what could be wrong?

Source Code Organization

The FreeRTOS download contains the source code for all the FreeRTOS ports.

See the Source Code Organization section for a description of the downloaded files and information on creating a new project.

The CrossWorks project used to build the MSP430 FreeRTOS demo is located in the Demo/msp430_CrossWorks directory. This project can be used to build both CrossWorks ports. See Selecting the Port to Use for information on switching between the two CrossWorks ports, along with some details of their differences.


The Demo Application

Functionality

The ES449 prototyping board includes a built in LCD display and a single built in user LED. To make use of this hardware, the standard demo tasks that would normally flash an LED, instead flash '*' characters on the LCD. The left most '*' represents LED 0, the next LED 1, etc.

The single on board LED is used by one of the ComTest tasks. It is toggled every time a character is received on the serial port.

The demo application creates 10 tasks - 9 of the standard demo application tasks and the idle task. When executing correctly the demo application will behave as follows:

Demo application hardware setup

The demo application includes tasks that send and receive characters over the serial port. The characters are transmitted by one task and received by another - if any character is missed or received out of sequence an error condition is flagged. Normally a loopback connector is required for this mechanism to work (so each character transmitted by the UART is also received by the UART). In this case the 'loopback' mode of the MSP430 UART is used and no external connector is required.

The demo application uses the LCD in place of LEDs so no other hardware setup is required.


Building

To build the demo application:
  1. Open the project file FreeRTOS/Demo/MSP430_CrossWorks/RTOSDemo.hzp from within the CrossStudio IDE.

  2. Select the required build (Debug or Release).


    Selecting the required build

  3. Select "Build Solution" from the CrossStudio project menu or simply press F7.


Downloading and executing

To download the application to the target hardware:
  1. Connect the FETP JTAG interface between the target and host. The target will be powered via the FETP JTAG interface and no other power source should be connected.

  2. Select "Connect MSP430 Flash Emulation Tool" from the CrossStudio Target menu.

  3. Select "Start Debugging" from the CrossStudio Debug menu. The MSP430 Flash will be automatically programmed with the demo application.
Once the application has been programmed into flash it can executed within the CrossStudio debugger. Alternatively, stop the debugger (to power down the target), remove the FETP JTAG interface, then supply the target with an external power source.


Configuration and Usage Details

Serial port driver

As provided the serial port drivers are configured for loopback mode. This enables the demo application to execute but switch loopback mode off for any other use.

It should also be noted that the serial drivers are written to test some of the real time kernel features - and they are not intended to represent an optimised solution.


RTOS Port specific configuration

Configuration items specific to this port are contained in Demo/MSP430_CrossWorks/FreeRTOSConfig.h. The constants defined in this file can be edited to suit your application. In particular - the definition configTICK_RATE_HZ is used to set the frequency of the RTOS tick. The supplied value of 1000Hz is useful for testing the kernel functionality but is faster than most applications require. Lowering this value will improve efficiency.

Each port #defines 'portBASE_TYPE' to equal the most efficient data type for that processor. This port defines portBASE_TYPE to be of type short.

Note that vPortEndScheduler() has not been implemented.


To use a part other than an MSP430F449

The core real time kernel components should be portable across all MSP430F4xx devices - but the peripheral setup and memory requirements will require consideration. Items to consider:

Switching between the pre-emptive and co-operative real time kernels

Set the definition configUSE_PREEMPTION within Demo/MSP430_CrossWorks/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 project.


Memory allocation

Source/Portable/MemMang/heap_1.c is included in the MSP430 demo 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.


Selecting the Port to Use

NOTE:This section provides in depth information. It is not necessary to modify any of the downloaded files, or necessarily understand all of this section in order to use the MSP430 port.

Two MSP430 ports are provided for the CrossWorks development suite:

  1. The first port is a effectively the same as the MSPGCC and is located in the FreeRTOS/Source/Portable/Rowley/MSP430F449/Port1 directory.

  2. The second port was provided by Milos Prokic and is located in the FreeRTOS/Source/Portable/Rowley/MSP430F449/Port2 directory.
The source code actually used by the demo application project is located in FreeRTOS/Source/Portable/Rowley/MSP430F449/. Therefore: A complete rebuild is required whenever switching from one port to another.


Interrupt service routines

In both ports an interrupt service routine that will never cause a context switch does not require any special consideration and can be declared as per the normal CrossWorks syntax.

Often you will require an interrupt service routine to cause a context switch. For example a serial port character being received may wake a high priority task that was blocked waiting for the character. If the ISR interrupted a lower priority task then it should return immediately to the woken task. How this is achieved depends on the port being used:

Complete examples of both formats are available in the file FreeRTOS/Demo/MSP430_CrossWorks/Serial/Serial.c.


Comparing the two ports

  1. Code size:

    Port1 uses assembly macros to save and restore the task context, whereas Port2 uses functions. This means Port1 will be faster, but Port2 will use less code space.

  2. Simplicity:

    Port1 is very simplistic, whereas Port2 is more elaborate. This elaboration results in the code space saving, but also requires a slightly more complex procedure to define interrupt service routines.

  3. Interrupt efficiency:

    Port1 uses the compiler generated function prologue and epilogue code to save and restore the necessary registers within an interrupt service routine (other than the RTOS tick ISR). Should a context switch be required from within the ISR the entire processor context is saved. This can result in some registers being saved twice - once by the compiler generated code, and then again by the FreeRTOS code.

    Port2 saves and restores all the processor registers within each interrupt service routine, whether or not a context switch actually occurs. This means no registers ever get saved twice, but imposes an overhead on the occasions that no context switch occurs.






Copyright (C) 2003 - 2008 Richard Barry
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 Richard Barry. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Richard Barry.