This article describes brief steps to setup a Linux development tools for MSP430 MCU – compiler and programmer. MSP430 is not as well linux-supported as AVR or 8051 but fortunately there are ways to make it working.
GCC
The easiest way for users of Debian and derived distributions is to add following repository to /etc/apt/sources.list:
deb http://merlin.fit.vutbr.cz/FITkit/download/debian debian fitkit
Then run as root:
# wget http://merlin.fit.vutbr.cz/FITkit/download/debian/debkey.asc -O- | apt-key add - # apt-get update # apt-get install msp430-devtools
After that you will have full toolchain. Lets try to compile the following C source:
#include <io.h>
void wait(void) //delay function
{
volatile int i; //declare i as volatile int
for(i=0;i<32000;i++); //repeat 32000 times
}
int main(void)
{
WDTCTL = WDTPW | WDTHOLD;
P1DIR=0xFF; //port 1 = output
P1OUT=0x01; //set bit 0 in port 1
for(;;) { //infinite loop
P1OUT=~P1OUT; //invert port 1
wait(); //call delay function
}
}
Compile the source and generate output suitable for programming the MCU:
$ msp430-gcc -Os -mmcu=msp430x2234 -o test.elf test.c $ msp430-objdump -DS test.elf > test.lst # assembler output $ msp430-objcopy -O ihex test.elf test.hex $ ls test.c test.elf test.hex test.lst
It’s done!
Programming
For this purpose there is all-in-one tool called mspdebug. It was originaly created for EZ430-RF2500 but now it supports all the MSP430 programmers. I’ve tested it with the RF2500 programmer. The easiest way to program the MCU’s flash is to run the following command:
$ mspdebug -R "prog test.hex" MSPDebug version 0.6 - debugging tool for MSP430 MCUs Copyright (C) 2009, 2010 Daniel Beer <daniel@tortek.co.nz> This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Trying to open interface 1 on 002 rf2500: warning: can't detach kernel driver: No data available FET protocol version is 30000002 Configured for Spy-Bi-Wire Set Vcc: 3000 mV Device: MSP430F22xx Erasing... Writing 120 bytes to e000... Writing 32 bytes to ffe0...
It’s done!
Note in the highlighted code the #include statement (using firefox) shows the lt and gt html formatting code this should be #include
. Not sure if it will even show up here right!!!
Comment by Scott Petler — 2011-02-16 @ 03:15
Hi! This is a “bug” in the syntax highlighter plugin. Fixed. Thanks!
Comment by admin — 2011-02-16 @ 11:26
Is there a license that this code is under? I’d like to redistribute it (with proper credit of course) on my site.
Comment by David DiPaola — 2011-06-19 @ 14:57
It is a fork of GNU GCC which is distributed under GNU GPL. It should/must have the same license.
Comment by admin — 2011-06-19 @ 18:38