MSP430 Quick Start

Intro to the development system

← Back to E15 Lab page ←

Setting up:

  1. Start Code Composer Studio; the icon () should be on the desktop.  Be patient, it takes a while to start up.  If your computer doesn't have Code Composer Studio (the free version here), install it (the computers in Hicks should have it).   You only need to install the MSP430 tools.
  2. Plug in the MSP430EZ - the USB drivers should load automatically.
  3. Start Code Composer Studio (CCS), and look through some of the introductory material.  It might be a good idea to do some of the tutorials.  Note that the "hello world" program won't run because the processor doesn't have enough resources.
  4. In CCS, go to File→New→CCS Project (Click >Next).  Choose a Project name (>Next).  Choose "MSP430" as "Project Type" (>Next). There are no "Additional Project Settings" (>Next).  Set the "CCS Project Settings" as shown (select the proper processor, for E15 it should be set to MSPF30F2012).

    Click "Finish" and wait a few seconds.
  5. Go to Window→Show View→C/C++ Projects.  Go to File→New→Source File and choose a name for your "C" source file. Make sure it ends in ".c". I called mine "Blinky.c"  The file should show up in the "C/C++ Projects" pane.

Program 1: Blinking an LED

This section of code will step you through the writing of a simple program that flashes an LED, downloading the code to the MSP430 and running it.

  1. Enter the following program:
    Note: change the name in the "include" statement to the appropriate one for your processor
    ("<msp430x20x3.h>" for the MSP430F2013, and "<msp430x20x2.h>" for the MSP430F2012).  Make sure there is a blank line after the last brace "}" or the compiler gives a warning.
    #include  <msp430x20x2.h>
    
    
    void main(void) {
    volatile int i;
        WDTCTL = WDTPW + WDTHOLD;         // Stop watchdog timer
        P1DIR = P1DIR | 0x01;             // Set P1.0 to output direction
        // Note: 0x01 = 0000 0001 binary (the LSB is set).
        
        while (1) {                       //Do this forever
            P1OUT = P1OUT ^ 0x01;         // Toggle P1.0 using exclusive-OR
            for (i=1; i<30000; i=i+1) {}  //Delay
        }
    }
    
  2. Go to Project →Build Active Project and make sure there is no error. 
  3. Go to Target →Debug Active Project.  The "Perspective" (shown in the upper right) should change to "Debug".
  4. Go to Target →Run.  The LED on the board should blink.  (Schematic of EZ430)
  5. Connect power to the jack on the E15 I/O board, and move the power jumper to the "uP" (for μP, or microProcessor) position.  Connect the MSP430 board to the E15 I/O board.  Look at the E15 I/O board schematic and figure out which LED will blink.  Run the code to make sure you were right.
  6. Look at the E15 I/O board schematic and change the code so the middle LED blinks.

Things to try:

Program 2:  Lighting an LED on command

The previous program blinked an LED with no user input.  Let's change that so you interact with the program.  First note that there is a pushbutton switch on the E15 I/O board connected to P2.6.  When the button is not pushed, the pin is tied to Vdd through a resistor (logic high).  When the button is pushed, the pin is connected directly to ground (logic low).

#include  <msp430F2012.h>

void main(void) {
    WDTCTL = WDTPW + WDTHOLD; // Stop watchdog
    P1DIR = P1DIR | BIT0;     // P1.0 output
    // note: BIT0 is predefined to be 0x01=0000 0001 binary (BIT 0)
    P2SEL = P2SEL & ~BIT6;    //Clear select bit (makes P2.6 an input)
    // note: BIT6 is predefined to be 0x40=0100 0000 binary (BIT 6)

    while(1) {
        if (!(P2IN & BIT6)) {      // If button is pushed (P2.6 is low)
            P1OUT = P1OUT | BIT0;  //   ... turn on LED
        } else {
            P1OUT = P1OUT & ~BIT0; //   ... else turn it off.
        }
    }
}

Please contact me if there is a problem with this web page (e.g., errors, or sections that are unclear).

← Back to E15 Lab page ←