Getting Started with the MSP430

I hear and I forget; I see and I remember; I do and I understand.

– Old Chinese Proverb

This tutorial is heavy with practical aspects of using the MSP430, and we hope you can follow the code, try and play with it. But, before we dive into number systems and operations we want to show you the reason we need to understand them. We believe that only by seeing code and running it will you begin realizing what pieces need to be understood to use the MSP430. This chapter will take you through a complete sample project. You might not understand all the code right away, but it will become clearer as we progress.

First Project in Code Composer Studio

We assume that you have been able to download and install Code Composer Studio, preferably version 5.5 or above. You can get a 90-day evaluation version from TI, or run it as a code size limited version. Although we’re using version 5.5, most v5.x versions will work. The most important thing to ensure is that support for the MSP430 was enabled during installation, since CCS supports many TI devices simultaneously. Installation isn’t particularly difficult, but the download can take a while.

The first step is to open Code Composer Studio and create a workspace. In the Select a Workspace dialog specify a folder name, even if one doesn’t exist. Although for this first project we will place the project with the workspace for simplicity, during development it is best to separate them. The workspace is not usually needed for development. A project can be added to any workspace. CCS will open with several windows, but they are full of information we don’t need. Go to the Project menu and then New CCS Project. We will create a project for the classic MSP430 Launchpad, which contains a MSP430G2553, so the dialog should be configured as follows:

Creating the First Project in Master the MSP430 Tutorial

Creating an Empty project (with main.c) simplifies creating the initial main.c file. The project will compile but do nothing. Replace the contents of main.c with the code below:

 
#include <msp430.h>
int i = 0;
void main()
{
    WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
    P1DIR |= 0x01;
    while(1)
    {
        P1OUT ^= 0x01;
        for(i = 0; i < 20000; i++);
    }
}

Press CTRL+B or go to Project-> Build All. CCS will build the project and since our code is valid and it will compile and link. If all goes well, CCS will inform you in the console window that linking is complete. Note that CCS takes care of both compilation and linking specifically for the MSP430 we specified, so that all the code will be placed in the correct flash locations when downloaded. If you have a Launchpad, connect it to the computer. It should automatically detect and install the drivers needed to run. CCS provides the drivers in its installation directory, so point windows there if needed.

Now press F11 or go to Run->Debug. If asked about low power, just press Proceed. CCS will download the code to the MSP430 and stop at the first line of main(). Press run and you will begin to see the LED blinking on the Launchpad.

Now that we have gone through at least one example, let’s begin our deep dive into the specifics.

SUBSCRIBE

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Related Articles