Getting started with MSP430 Launchpad on Debian

Published on: 2011-9-18

Home | Archive

Getting started with MSP430 Launchpad on Debian

Sep 18, 2011

I am trying to get some demos running with an EzChronos and a couple of MSP430 Launchpad's. Here is a brief outline of the steps required to get your first "hello,world" running.

I had installed the MSP430 toolchain on a few machines sometimes back. The procedure was simple - pull out a set of scripts/patches from here and run one of the supplied scripts - this takes care of getting the core components - binutils, libc and gcc, applying the patches and building them. The procedure was painless. But it seems that the developers have abandoned this approach - the procedure to build the latest version (msp430-gcc version 4.5.3) is to download all the core components, apply the patches and do the build manually. This takes a bit more effort. Here is a document describing the process.

I was doing the build on Debian Squeeze - everything worked fine except when it came to building gcc. The version of GCC that was being compiled required newer versions of three libraries - gmp, mpfr, and mpc. The sources for these three libraries had to be downloaded and built following the instructions given here. Also, gdb ver 7.2 was not avaible - but ver 7.2a worked fine.

There is an excellent tool called mspdebug which can be used for flashing the MSP430G2231 on the launchpad and also for debugging.

Once the toolchain and "mspdebug" are built properly, we can write our "hello,world" program - lighting up an LED connected to P1.0 of the processor:

#include 
main() 
{
   WDTCTL = WDTPW + WDTHOLD;
   P1DIR = 1; P1OUT = 1;
}

The first line is for disabling the watchdog - a compile time option, "-mdisable-watchdog" can be used to do this in the C library startup code itself.

Compile the code with:

msp430-gcc -mmcu=msp430g2231 led.c

Flashing is done by invoking "mspdebug rf2500" and executing the commands:

erase
prog a.out