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

__attribute__((interrupt(TIMERA0_VECTOR)))
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)

__attribute__((interrupt(VECTOR_NAME)))
void irq_handler_for_vector(void);

with VECOR_NAME the name of the IRQ vector. example:

__attribute__((interrupt(USCI_A2_VECTOR)))
void usbRxISR(void){ 

Thank you Matthias - for this alternative.