"Think outside the [B0X]"

Msp430 Hello World, … Blinky!

This is a short example how to get started with Texas Instrument (TI) msp430 Micro controller.

Let’s get started with the mother of all examples, hello world , or blinky for the microprocessor world.

This example presume you have installed:

  • the usb driver to connect the msp430 to
  • TI Code Composer Studio (CCS)

Info about installing the usb and/or CCS

With CCS started, go to File -> new -> CCS Project to open “New CCS Project” wizard

CCS Project Wizard

CCS Project

  1. Project name: HelloWorld
  2. Click next

Select A type of project

  1. Project type: 430
  2. Click next

Additional Project Settings

Ignore this section for now, proceed with next.

CCS Project Settings

In this section, make sure to select the right device. Otherwise the wrong header files are included in the project. The msp430 eZ430-RF2500 is used and it is an MSP430 F2274 according the documentation on TI site.

  1. Select Device
  2. Click finish to complete the wizard

For now CCS looks pretty empty and it is time to add some code.

Create a new folder in the project and name it “applications”

In the newly created folder, create a file and name it “HelloWorldMain.c”

Enter following code:

#include <msp430x22x4.h>

int main(void) {
   unsigned int count;
   WDTCTL = WDTPW + WDTHOLD; //Stop watchdog timer

   P1OUT = 0; //Configure P1 to output on P1.0
   P1DIR |= 0x01;

      P1OUT ^= 0x01; //Toggle P1.0 using exclusive-OR
      for(count=0; count<60000; count++){ /* Insert some delay */ }

Build & load

Build the project: Project->Build Active Project
Pay attention to the console and it should end with:

Build complete for project HelloWorld

Loading the program in msp430

Use USB to connect the msp430 to the computer. Depending the type of development tool, this can be a dongle or with a USB cable to the launch board.

In CCS, Target->Debug Active Project

For now, the msp430 is still doing nothing, because by default the CSS debug stops at entry of the main block.


Hit F8 to run, …

Magically, Led 1 starts to blink.

Congratulations, these are your first steps in the microcontroller world using TI msp430!

Category: Dev notes

Tagged: , , ,