gcb 0 Posted May 30, 2012 Share Posted May 30, 2012 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. Quote Link to post Share on other sites
gcb 0 Posted May 30, 2012 Author Share Posted May 30, 2012 btw ...should i be using something else than msp430-gcc? Quote Link to post Share on other sites
gordon 229 Posted May 30, 2012 Share Posted May 30, 2012 The only thing you need is msp430.h (and the libc headers should you use libc, of course) and the correct -mmcu= setting. Quote Link to post Share on other sites
gcb 0 Posted May 30, 2012 Author Share Posted May 30, 2012 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.cuart.c:36:6: warning: return type of Quote Link to post Share on other sites
rockets4kids 204 Posted May 30, 2012 Share Posted May 30, 2012 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) { } Quote Link to post Share on other sites
Fe2o3Fish 33 Posted May 30, 2012 Share Posted May 30, 2012 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- Quote Link to post Share on other sites
gordon 229 Posted May 30, 2012 Share Posted May 30, 2012 ... and if you use 4.6 (the current LTS), it understands most other variations without having to jump hoops. Quote Link to post Share on other sites
pabigot 355 Posted May 30, 2012 Share Posted May 30, 2012 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). Quote Link to post Share on other sites
rockets4kids 204 Posted May 30, 2012 Share Posted May 30, 2012 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. ;-) Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.