The demo documented on this page is deprecated as it has been superseded by demos that use later hardware and tool versions.
IntroductionThis page documents the FreeRTOS demo application for the MSP430F5438 microcontroller (with an MSP430X core) from Texas Instruments. The demo uses the MSP430 Code Composer Studio IDE and compiler, and targets the official MSP-EXP430F5438 experimenter board from TI (instructions are provided should you wish to use an alternative development board).
The port and demo project were developed and tested using the 'Large' and 'Small' data models, and the 'Large' and 'Small' code models.
Features of FreeRTOS that are demonstrated by this demo projectThe project demonstrates the following FreeRTOS features and techniques:
IMPORTANT! Notes on using the MSP430X CCStudio 4 DemoPlease read all the following points before using this RTOS port.
My application does not run, what could be wrong?
Source Code OrganisationThe FreeRTOS download contains the source code for all the FreeRTOS ports so includes many more files than are required for this demo. See the Source Code Organization section for a description of the downloaded files and information on creating a new project.
The CCS project file for the MSP430F5438 demo is located in the FreeRTOS/Demo/MSP430X_MSP430F5438_CCS4 directory. This is the project that should be imported into the CCS workspace. The Preparing the Eclipse project section below contains important information on setting up the demo project directory, and importing the demo project into Code Composer Studio.
The Demo Application
Demo application hardware setupThe demo application includes an interrupt driven UART test. This creates two tasks, a transmit task and a receive task. The transmit task transmits characters on UCA1, and the receive task receives characters on the same UCA1 peripheral. The receive task expects to receive the characters transmitted by the transmit task, but as there is no external 9 way connector, the hardware is internally configured to use a loopback mode. Therefore, unlike other FreeRTOS demos, it is not necessary to fit an external loopback connector to the UART for the COM port test to work.
Note that the implementation of the UART interrupt service routine is provided to demonstrate the use of queues from inside an interrupt service routine. It is not intended to be an example of an efficient interrupt implementation. A real application should make use of the DMA. Or, as a minimum, transmission and reception could use a simple RAM ring buffer, and synchronise with a task using a semaphore when a complete message has been received or transmitted.
The port was developed and tested using a Texas Instruments MSP-FET430UIF USB debug interface.
CreateProjectDirectoryStructure.bat must be executed before the Code Composer Studio project is imported into the Eclipse workspace.
CreateProjectDirectoryStructure.bat cannot be executed from within the Code Composer Studio Eclipse IDE.
Importing the demo application project into the CCS Eclipse workspaceTo import the MSP430X CCS project into an existing or new Eclipse Workspace:
Building and running the demo application
FunctionalityThe top of this web page lists the FreeRTOS features that are demonstrated by the MSP430X5438 demo project. The comments contained in the main.c source file provide more information on how this functionality is implemented and achieved.
The following behaviour will be observed when the demo is executing correctly:
RTOS Configuration and Usage Details
Configuring the RTOS tick interruptFreeRTOS requires exclusive use of a timer that is capable of generating a fast 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 time 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.
RTOS port specific configurationConfiguration items specific to these demos are contained in FreeRTOS/Demo/MSP430X_MSP430F5438_CCS4/FreeRTOSConfig.h. The constants defined in this file can be edited to meet the needs of your application. In particular -
Each port #defines 'BaseType_t' to equal the most efficient data type for that processor. This port defines BaseType_t to be of type short.
Note that vPortEndScheduler() has not been implemented.
Interrupt service routinesUnlike 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 that portYIELD_FROM_ISR() must be the last statement in the ISR.
This demo project provides examples of FreeRTOS interrupt service routines - namely prvSelectButtonInterrupt() defined in main.c and 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!
Switching between the pre-emptive and co-operative RTOS kernelsSet the definition configUSE_PREEMPTION within FreeRTOS/Demo/MSP430X_MSP430F5438_CCS4/FreeRTOSConfig.h to 1 to use pre-emption or 0 to use co-operative.
Compiler optionsAs 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.
Memory allocationSource/Portable/MemMang/heap_2.c is included in the 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.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
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.
FreeRTOS and other embedded software careers at AWS.