Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


TI MSP430FR5969 (MSP430X) RTOS Demo
Supporting IAR, and TI (CCS) compilers
[RTOS Ports]


Texas Instruments MSP430 MSP-EXP430FR5969 Launchpad Development Kit
The MSP-EXP430FR5969 LaunchPad Development Kit

Introduction

This page documents the RTOS demo application that targets the Texas Instruments MSP430FR5969 low power microcontroller, which has a 16-bit MSP430X core.

Pre-configured projects that target the MSP-EXP430FR5969 Launchpad Development Kit are provided for both the IAR and Code Composer Studio (CCS) MSP430 compilers:

Each project can be compiled to create either a simple blinky demo, or a comprehensive test and demo application that includes a FreeRTOS+CLI command line interface. Further, build configurations are provided that use both the large and small data models.

A note on low power support

The Idle hook is used to place the MSP430 MCU into a low power mode as a crude method of saving power. The provision of a tickless idle implementation would significantly improve the power saving that could be achieved, but is not configured in this demonstration.


FreeRTOS kernel aware debugger used with the IAR compiler
Screen shot of the FreeRTOS state viewer plug-in
that ships with the IAR IDE. Click to enlarge.




IMPORTANT! Notes on using MSP430X RTOS 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 RTOS source code download contains the files for every FreeRTOS port and every demo application, so contains many more files than are required by the MSP430FR5969 demo. See the Source Code Organization section of this website for a description of the downloaded files.

The IAR and CCS projects are both located in the /FreeRTOS/Demo/MSP430X_MSP430FR5969_LaunchPad_IAR_CCS directory:

  • The IAR Embedded Workbench for MSP430 (EW430) project is called RTOSDemo.eww

  • The CCS project has the usual Eclipse project name .project



Building and Running the MSP430FR5969 MSP430X RTOS Application

The RTOS demo projects can be configured to build a simple blinky project, or a comprehensive test and demo application. The constant mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is used to switch between the two. mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is defined at the top of main.c.

  • The simple blinky demo is created if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1.
  • The comprehensive demo is created if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 0.

The demo uses an LED built onto the MSP-EXP430FR5969 Launchpad development kit, so no hardware setup is required.

The following sub-sections provide instructions on using the tool chains for which pre-configured projects are provided.

  1. Building with the IAR Embedded Workbench
  2. Building with Code Composer Studio


Building with IAR Embedded Workbench

  1. Open FreeRTOS/Demo/MSP430X_MSP430FR5969_LaunchPad_IAR_CCS/RTOSDemo.eww in the IAR Embedded Workbench IDE.

  2. Select either the large of small data model build configuration as shown in the image below (see the data model section section under the RTOS Configuration and Usage Notes heading for special information on switching data models using IAR).

  3. Select "Rebuild All" from the IAR Embedded Workbench "Project" menu (or press F7) to build the demo project.

  4. Ensure the MSP-EXP430FR5969 Launchpad hardware is connected to the host computer.

  5. Select "Download and Debug" from the IAR Embedded Workbench "Project" menu to program the microcontroller flash memory and start a debug session.


Selecting the large or small data model
build configuration using the IAR IDE

Note: The IAR project can fail to build and get corrupted (so it can no longer be used with any IAR version) if it is opened in a version of EW430 that is older than the version that was used to originally create the project.


Building with TI Eclipse based Code Composer Studio (CCS)

  1. Start the CCS Eclipse IDE, and either create a new or select an existing workspace when prompted.

  2. Select "Import" from the IDE's "File" menu. The dialogue box shown below will appear. Select "Code Composer Studio->CCS Projects", as shown below.

    Importing the MSP430 RTOS demo project into the CCS Eclipse IDE
    The dialogue box that appears when "Import" is first clicked


  3. In the next dialogue box, select /FreeRTOS/Demo/MSP430X_MSP430FR5969_LaunchPad_IAR_CCS as the root directory. Make sure the RTOSDemo project is checked in the "Projects" area, and that the Copy Projects Into Workspace box is not checked, before clicking the Finish button (see the image below for the correct check box states).

    Selecting the RTOS source code when importing into Eclipse CDT
    Make sure RTOSDemo is checked, and "Copy projects into workspace" is not checked


  4. Select either the large of small data model build configuration. See the image below.

  5. Select "Build All" from the CCS Eclipse "Project" menu to build the demo project.

  6. Ensure the MSP-EXP430FR5969 Launchpad hardware is connected to the host computer.

  7. Select "Debug" from the Eclipse "Run" menu to program the microcontroller's flash memory and start a debug session.


Selecting the large or small data model build configuration using the CCS IDE

Note: The CCS project references files using relative paths, including FreeRTOS+CLI files from the /FreeRTOS-Plus directory. The project may fail to build if a directory path is changed or if a file is moved. Eclipse's 'export' features can be used to convert the project into a stand-alone project that only uses directories under the directory in which the .project file is located.


Demo Application Functionality

The simply blinky example

mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is defined at the top of main.c. When mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1 main() will call main_blinky():
  • The main_blinky() Function:

    main_blinky() creates a queue, a queue send task, and a queue receive task, before starting the scheduler.

  • The Queue Send Task:

    The queue send task is implemented by the prvQueueSendTask() function in main_blinky.c.

    prvQueueSendTask() sends the value 100 to the queue every 200 milliseconds.

  • The Queue Receive Task:

    The queue receive task is implemented by the prvQueueReceiveTask() function in main_blinky.c.

    prvQueueReceiveTask() blocks to wait for data to arrive on the queue, unblocking and toggling an LED each time the queue send task writes to the queue. As the queue send task writes to the queue every 200 milliseconds, the queue receive task will unblock and toggle the LED every 200 milliseconds.


The comprehensive test and demo application


Sample CLI session
The comprehensive demo includes a command line interface (CLI) on which both task and run-time statistics can be viewed. Instructions on connecting to and using the CLI are provided below.

Note: The CLI output is sporadic when the demo application is executing in the debugger, but much smoother when the demo application is executing standalone.

mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is defined at the top of main.c. When mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1 main() will call main_full():

  • The main_full() Function:

    main_full() creates a set of standard demo tasks, the CLI, the Check task, the Register Test tasks, and starts the scheduler.

  • The "Reg Test" Tasks:

    The reg test tasks test the context switching mechanism by filling each MCU register with a known value, then continuously checking that each register maintains its expected value for the lifetime of the task.

  • The "Check" Task:

    The "Check" task monitors the status of all the other tasks in the system, looking for a task either stalling or reporting an error. It toggles an LED each time it is called.

    If the LED is toggling every three seconds then the check task has determined the demo is running as expected. If the LED is toggling every 200ms then at least one potential error has been found.


To connect to the CLI:

  1. Run the comprehensive demo. A UART on the MPS430FR5969 will enumerate as a virtual COM port called "MSP Application UART1" on the host computer.

  2. Open a dumb terminal program, such as Tera Term or Hyper Terminal, and connect to the enumerated COM port at 19200 baud.

  3. As always with FreeRTOS+CLI - type "help" into the console to see a list of registered commands. An example CLI session is shown on the right.



RTOS Configuration and Usage Details

Data models

The RTOS supports both the large and the small data model. The data model is selected using the build options in the chosen IDE.

Note for IAR users: If you are using the IAR tools then there is an additional step that must be performed when configuring FreeRTOS as follows:

  • If the large data model is used then __DATA_MODEL_LARGE__ must be defined as an assembler (not compiler) symbol. See the image below.

  • If the small data model is used then __DATA_MODEL_SMALL__ must be defined as an assembler (not compiler) symbol. See the image below.


Defining the necessary assembler symbol

Configuring the RTOS tick interrupt

FreeRTOS requires exclusive use of a timer that is capable of generating a periodic interrupt called the RTOS 'tick' interrupt. The timer is configured in a user definable hook (or callback) function, so giving the application writer the flexibility to decide which timer peripheral is actually used. The name and prototype of the hook function is shown below:
void vApplicationSetupTimerInterrupt( void );
The constant configTICK_VECTOR must be set to the interrupt vector number of the chosen peripheral. configTICK_VECTOR is defined in the FreeRTOSConfig.h header file. This demo project includes an implementation of vApplicationSetupTimerInterrupt() that configures timer TA0 to generate the tick interrupt and therefore sets configTICK_VECTOR to TIMER0_A0_VECTOR. The provided code will have to be modified only if the application being developed needs TA0 to be free for some other purpose.


Interrupt service routines

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 portYIELD_FROM_ISR() can be used to request a context switch from within an ISR. Note: portYIELD_FROM_ISR() must be the last statement in the ISR.

This demo project provides examples of FreeRTOS interrupt service routines - including prvUSCI_A0_ISR() defined in serial.c. Note that prvUSCI_A0_ISR() is implemented to stress the port and demonstrate queues being used from interrupts - it is not intended to be a demonstration of an efficient or a generic interrupt service routine!


RTOS port specific configuration

Configuration items specific to these demos are contained in the FreeRTOSConfig.h file located in the same directory as the project file. The constants defined in FreeRTOSConfig.h can be edited to meet the needs of your application. In particular -
  • configTICK_RATE_HZ

    This sets the frequency of the RTOS tick interrupt. The supplied value of 1KHz is useful for testing the RTOS kernel functionality, but is faster than most applications require. Lowering this value will improve efficiency.

Each port #defines 'BaseType_t' to equal the most efficient data type for that processor. The MSP430X RTOS port defines BaseType_t to be of type short.

Note that vPortEndScheduler() has not been implemented.


Memory allocation

Source/Portable/MemMang/heap_4.c is included in the MSP430X 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 full information.





[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner