Jump to content
Sign in to follow this  
gcb

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

 

#include

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

Share this post


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

http://mspgcc.sourceforge.net/manual/x918.html

 

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

Share this post


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
#include 
#define NORETURN __attribute__ ((noreturn))
#define ISR(a, void __attribute__((interrupt (a))) b (void)
#else // CCS/IAR
#include 
#define NORETURN 
#define __PRAGMA__(x) _Pragma(#x)
#define ISR(a, \
__PRAGMA__(vector=a) \
__interrupt void b(void)
#endif

 

And then define an interrupt service routine like this:

 

ISR (WDT_VECTOR, watchdog_timer)
{
}

Share this post


Link to post
Share on other sites

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

#include 
#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.

 

-Rusty-

Share this post


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).

Share this post


Link to post
Share on other sites

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).

 

Which is exactly why I roll my own macros to take care of the issue. ;-)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×