element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Safe and Sound
  • Challenges & Projects
  • Design Challenges
  • Safe and Sound
  • More
  • Cancel
Safe and Sound
Blog MSP432 and TI-RTOS: Getting Started Pt. 1 - Set Up and 1st RTOS Task
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 28 Dec 2016 2:49 PM Date Created
  • Views 1878 views
  • Likes 10 likes
  • Comments 3 comments
  • safe and sound
  • rtos
  • msp432
  • ti-rtos
  • launchpad
  • feature_tutorial
  • ti_rt
Related
Recommended

MSP432 and TI-RTOS: Getting Started Pt. 1 - Set Up and 1st RTOS Task

Jan Cumps
Jan Cumps
28 Dec 2016

A few easy steps to get an RTOS project running on the MSP432 LaunchPad

image

 


When you complete this example, you have a basic RTOS setup that integrates USB, ADC and a blinky. You can use Tasks, Semaphores and a UART interrupt. And you'll know how to register Tasks in the TI-RTOS configuration editor.

 

Part 1 sets up the project, explains how to configure a task and gets the Blinky running.

 

What you need:

  • MSP432 LaunchPad
  • 1 micro-USB cable
  • Code Composer Studio
  • TI-RTOS for MSP43X

 

image

 

Starting a Project

I start by importing the TI-RTOS "Empty" example. It's a pretty decently configured start point.

With a few clicks you have a running project that you can test out right away. Your LaunchPad's LED1 will blink once per minute if you've done things right.

 

Follow these steps to import the project:

Start Code Composer Studio.

Menu View -> Resource Explorer

Navigate to TI-RTOS for MSP43x -> Development Tools -> MSP-EXP432x -> Driver Examples -> Empty Examples -> Empty Project

image

Click the Import to IDE button.

You now have a project named empty_MSP_EXP432P401R_TI.

 

Build it and execute via the debugger. Check if the red led at the left bottom corner of the LaunchPad is blinking.

Enjoy your first success. You have shown that you have an RTOS program that compiles and runs fine.

When you have looked at the led for a few hours, stop the debugger. The led will keep on blinking.

 

Rename the project and any file with "empty" in the name to something meaningful.

I'm using "datalogger" for this example.

 

The project name becomes "datalogger_MSP_EXP432P401R_TI". Right-click on the project root in the Project explorer and select Rename....

image

Then rename the following files by rightclicking on them selecting rename:

empty.c -> datalogger.c

empty.cfg -> datalogger.cfg

 

Build and run the project again. That will show that you have successfully completed the steps.

There's more to this example than meets the eye. You get the basic logging and instrumentation skeleton. And the controller is configured to go to low-energy mode when idle.

image

 

Configure the Blinky Task

The empty project registers the blinky task with code.

    /* Construct heartBeat Task  thread */
    Task_Params_init(&taskParams);
    taskParams.arg0 = 1000;
    taskParams.stackSize = TASKSTACKSIZE;
    taskParams.stack = &task0Stack;
    Task_construct(&task0Struct, (Task_FuncPtr)heartBeatFxn, &taskParams, NULL);

 

That's fine (you can also see the convention - used by many - to pass the scheduling time as arg0). You can use that method if you prefer.

In TI-RTOS, you can also set up the task with the configuration editor.

The result for your firmware is exactly the same, but you get some additional advantages:

  • all tasks and their priorities, stack size and timings available in one place
  • an editor to view and change task settings
  • a cleaner main()

 

Let's start by removing the program code that sets up our Blink task from datalogger.c. Just write down the settings that are used to create the task

Did that for you image : Stacksize 512, Sleep time 1000

 

Remove the following lines:

#define TASKSTACKSIZE   512


Task_Struct task0Struct;
Char task0Stack[TASKSTACKSIZE];

 

and:

    Task_Params taskParams;
    // ...    
    /* Construct heartBeat Task  thread */
    Task_Params_init(&taskParams);
    taskParams.arg0 = 1000;
    taskParams.stackSize = TASKSTACKSIZE;
    taskParams.stack = &task0Stack;
    Task_construct(&task0Struct, (Task_FuncPtr)heartBeatFxn, &taskParams, NULL);

 

and configure the scheduling again in the TI-RTOS configuration editor.

Double-click on datalogger.cfg. In the outline view on the right, select the Task node. Click Add....

image

 

 

A new form opens that lets you set the parameters:

image

Enter a name for the task handle. In the Function field, use the exact name of the blinky task (heartBeatFxn).

Priority is 1 (very low). The LED will give us a quick view into the RTOS scheduler health.

If the scheduler can't cope with the load, the rhythm of the LED will become irregular.

That's a great help during the development cycle.

Set the Stack size  and Argument0 value to those you've written down before.

Press the Save All button to apply the changes to both files we edited.

 

Build and execute again. The program behaves exactly the same as before.

That's what we wanted.

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

Next

In the next blog I'll add an a new task. I'll also ad the ADC driver and integrate sampling into the project.

For those playing along, here's the content of datalogger.c after the changes:

/*
 * Copyright (c) 2015, Texas Instruments Incorporated
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * *  Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * *  Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * *  Neither the name of Texas Instruments Incorporated nor the names of
 *    its contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/*
 *  ======== empty.c ========
 */
/* XDCtools Header files */
#include <xdc/std.h>
#include <xdc/runtime/System.h>

/* BIOS Header files */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>

/* TI-RTOS Header files */
#include <ti/drivers/GPIO.h>
// #include <ti/drivers/I2C.h>
// #include <ti/drivers/SDSPI.h>
// #include <ti/drivers/SPI.h>
// #include <ti/drivers/UART.h>
// #include <ti/drivers/Watchdog.h>
// #include <ti/drivers/WiFi.h>

/* Board Header file */
#include "Board.h"

/*
 *  ======== heartBeatFxn ========
 *  Toggle the Board_LED0. The Task_sleep is determined by arg0 which
 *  is configured for the heartBeat Task instance.
 */
Void heartBeatFxn(UArg arg0, UArg arg1)
{
    while (1) {
        Task_sleep((UInt)arg0);
        GPIO_toggle(Board_LED0);
    }
}

/*
 *  ======== main ========
 */
int main(void)
{
    /* Call board init functions */
    Board_initGeneral();
    Board_initGPIO();
    // Board_initI2C();
    // Board_initSDSPI();
    // Board_initSPI();
    // Board_initUART();
    // Board_initWatchdog();
    // Board_initWiFi();

    /* Turn on user LED */
    GPIO_write(Board_LED0, Board_LED_ON);

    System_printf("Starting the example\nSystem provider is set to SysMin. "
                  "Halt the target to view any SysMin contents in ROV.\n");
    /* SysMin will only print to the console when you call flush or exit */
    System_flush();

    /* Start BIOS */
    BIOS_start();

    return (0);
}

 

Good luck!

Little secret: works exactly the same for MSP430, TIVA / TM4C and the SimpleLink CC1310, CC2650, CC3200.

 

 

 

TI-RTOS Series
MSP432 and TI-RTOS: Getting Started Pt. 1 - Set Up and 1st RTOS Task
MSP432 and TI-RTOS: Getting Started Pt. 2 - Add an ADC Sample Task
MSP432 and TI-RTOS: Getting Started Pt. 3 - USB with Minimal CPU Use
MSP432 and TI-RTOS: PWM
MSP432 and TI-RTOS: I2C Configuration for Sensors BoosterPack
MSP432 and TI-RTOS: another I2C example - talk to a DAC
MSP432 and TI-RTOS: Sharp LCD BoosterPack
MSP432 and TI-RTOS: PID Library Part 1 - Intro
MSP432 and TI-RTOS: PID Library Part 2 - Real World Example
  • Sign in to reply

Top Comments

  • DAB
    DAB over 8 years ago +3
    Great post Jan. Now I have more confidence to look into TI-RTOS for future projects. DAB
  • jwatson
    jwatson over 8 years ago in reply to Jan Cumps +2
    Brilliant! Thanks Jan. Jane
  • Jan Cumps
    Jan Cumps over 8 years ago in reply to DAB +1
    I'm more comfortable with RTOSses these days, Don. Whenever I have a requirement for non-blocking serial communication, wifi/ethernet or Bluetooth. I tend to use (or in some cases have to use) an RTOS…
  • jwatson
    jwatson over 8 years ago in reply to Jan Cumps

    Brilliant! Thanks Jan.

    Jane

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 8 years ago in reply to DAB

    I'm more comfortable with RTOSses these days, Don. Whenever I have a requirement for non-blocking serial communication, wifi/ethernet or Bluetooth. I tend to use (or in some cases have to use) an RTOS.

    Also when I expect more than simple scheduling requirements, I'm choosing the rtos route.

     

    I worked with FreeRTOS and the TI one. I started with FreeRTOS. I had to invest lots of time and effort to become fluent. But it made learning TI-RTOS easy.

     

    There is someone here on element14 that's building a C++ rtos. I haven't tried it, I'm just following the discussions at the moment.

    I've become a little too lazy these days to create my own port for the devices I use.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 8 years ago

    Great post Jan.

     

    Now I have more confidence to look into TI-RTOS for future projects.

     

    DAB

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube