Jump to content

msp430-gcc and signals.h deprecated

Recommended Posts

pretty much all the code/tutorials i find about interrupts use signal.h and it's macros.


and signal.h on my current headers (msp430-gcc (GCC) 4.5.3) complains it's deprecated and

1) should not be used

2) use legacymsp430.h


well, i tried #2 first, it fails.


then i tried to see what I should be using instead, and failed. everything i found uses signal.h


Any doc/sample code i should be looking?


the manuals is all about signal.h

(link to manual that i can't include because new users can't post links)


Writing interrupt service routines


mspgcc allows interrupt service routines to be written efficiently in C. To access the interrupt features of mspgcc the header file



should be included in any source files where interrupt service routines are defined.

Link to post
Share on other sites
The only thing you need is msp430.h (and the libc headers should you use libc, of course) and the correct -mmcu= setting.



and how do i declare the interrupts?


the manual says to use signal.h



The code i find around uses magic strings that i can't find in msp430.h, e.g.

interrupt(PORT1_VECTOR) Port_1(void) {


which fail:

msp430-gcc -Os -Wall -g -mmcu=msp430g2231 -c uart.c

uart.c:36:6: warning: return type of

Link to post
Share on other sites

I'm not sure if there is a "proper" way, but here is how I set up interrupt handling so that the same code will work under GCC and CCS:


#if defined (__GNUC__)  // mspgcc
#define NORETURN __attribute__ ((noreturn))
#define ISR(a, void __attribute__((interrupt (a))) b (void)
#else // CCS/IAR
#define NORETURN 
#define __PRAGMA__(x) _Pragma(#x)
#define ISR(a, \
__PRAGMA__(vector=a) \
__interrupt void b(void)


And then define an interrupt service routine like this:


ISR (WDT_VECTOR, watchdog_timer)

Link to post
Share on other sites

For what it's worth, this is what I use without complaints:

#define interrupt(x) void __attribute__((interrupt (x)))

interrupt(TIMERA1_VECTOR) Timer_A(void)
   /* ISR */

Naturally, your vector name will vary. :-)

This is for msp430-gcc version 4.5.3 on Linux.



Link to post
Share on other sites
I'm not sure if there is a "proper" way...


For mspgcc, the proper way is the __attribute__((__interrupt__(x))) annotation, as everything else is simply syntactic sugar around that (mostly handled by macros in headers, as the old "signal.h" did). As gordon points out, LTS-20120406 also recognizes the TI #pragma syntax; in that case the sugar's hidden in the compiler, but it's still fundamentally an attribute.


There's also an isr_compat.h header you could use which has that ISR macro and isn't deprecated (though it also only gets looked at when somebody complains that it doesn't work anymore).

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...