MSP430 – different Interrupts for different compilers

The different compilers out there for msp430 chips and Launchpad have different syntax for each one –

Hopefully this post will help you find out which one you need.

(all examples are for chip msp430g2231, just substitute your chip that you are working with)

First – CSS/IAR — TI officially supported compilers/IDEs

#pragma vector=TIMERA1_VECTOR
__interrupt void Timer_A1(void)    { //ISR code




second – mspgcc4 – IDE of your choice

Makefile — must have this option to compile correctly to chip -mmcu=msp430x2231 –most chips are supported but you will have to find the correct one for yours.

Main.c file or main project file

you must include these

#include <msp430g2231.h>
#include <signal.h>

and then the syntax for your ISR

interrupt(TIMERA0_VECTOR) Timer_A (void) {  //code goes here}


Third — Uniarch mspgcc – Newest compiler – replacement for mspgcc4


makefile– -mmcu=msp430g2231   you must use the one specific for your chip and should not include an x in the mmcu option since that is for the depreciated mspgcc4

inlcude these header files

#include <msp430.h>
#include <legacymsp430.h>

ISR syntax

interrupt(TIMERA0_VECTOR) Timer_A (void)
{  //code goes here}


Fourth way– Offiacial uniarch mspgcc ISR syntax

makefile – same as before

no extra includes needed, just the msp430.h or specific chip header

void Timer_A(void){ //code goes here }

Source link


This is not complete, I am waiting for an answer on what the syntax should be for uniarch branch of mspgcc for interrupts. So far my testing has only allowed using interrupts using the lgacymsp430.h header. Once I get an answer I will update this post.

update —

so far this alternative works – (works == compiles with no errors)

The syntax for declaring an interrupt with gcc is (as far as I learnt so far)

void irq_handler_for_vector(void);

with VECOR_NAME the name of the IRQ vector. example:

void usbRxISR(void){ 

Thank you Matthias - for this alternative.

3 Responses to MSP430 – different Interrupts for different compilers

  1. Hi, I know, it is a while your post. My question is, are there compiler type #defines to separated code for the different compilers in one file or to load different libs?

    • It is usually #defines that seperate the code…..bit in recent versions mspgcc will allow you to compile code from either iar or ccs. but css and iar will not build mspgcc code with out changes.

      I need to put a disclamer on this page since it was written before mspgcc uniarch (current mspgcc) became the standard linux for msp430s.

      hope this answers your question.

  2. Thanks for the post, this helped, the MSPGCC is a bit hard to wade through!