MSP430 Toolchain on OSX Mavericks

Developing for the MSP430 and the TI Launchpad Development Kit on OSX 15 Aug 2014

Mavericks MSP430

Install the Drivers for the TI Launchpad

Compiling and Uploading Test Code to the TI Launchpad

Create the folowing files in a new directory

File main.c (text program code)

#include  <msp430g2553.h>

volatile unsigned int i = 0;

void main(void){
    WDTCTL = WDTPW + WDTHOLD;
    P1DIR |= 0x01;
    for (;;){
        P1OUT ^= 0x01;                          
        for(i=0; i< 20000; i++){
        }
    }
}

File Makefile (Defines compilation of the code)

DEVICE=msp430g2452
CC=msp430-gcc
CFLAGS=-Os -Wall -g -mmcu=$(DEVICE)
OBJS=main.o
SRCS=main.c

all: main.elf

main.c: watchdog.h

main.elf: $(OBJS)
	$(CC) $(CFLAGS) -o main.elf $(OBJS)

%.o: %.c
	$(CC) $(CFLAGS) -c $<

clean:
	rm -fr main.elf $(OBJS)

flash: main.elf
	mspdebug rf2500 "prog main.elf"

size: main.elf
	msp430-size main.elf

#for managing header file dependencies
depend: .depend

.depend: $(SRCS)
	rm -f ./.depend
	$(CC) $(CFLAGS) -MM $^ -MF  ./.depend;

include .depend

Change the DEVICE variable to match the one on the TI Launchpad

Compile the program:

$ make
$ make flash
$ make verify

You’re done! The program running on the microcontroller should now be blinking the LED on the Launchpad.