If you are using a LaunchPad then you could give Energia (http://energia.nu) (Arduino for the MSP430) a try if you want something higher level. It features an attachInterrupt() function that you can use to attach an interrupt on either falling or rising edge of any of the P1 or P2 pins. You can use the standard Arduino api documentation as a reference: http://arduino.cc/en/Reference/HomePage The attachInterrupt() API is documented here: http://arduino.cc/en/Reference/AttachInterrupt
LaunchPad pin mapping is documented here: https://github.com/energia/Energia/wiki/Hardware Robert On Oct 23, 2012, at 2:21 PM, Yama Ploskonka wrote: > I am so noob that only yesterday did I ever code using interrupts. > > What I want to achieve is a two-whisker robot, the kind that bounces off > the wall in either direction oposite from the whisker closing a switch. > Couldn't be simpler. > > Yet, I have totally been unable to find code that > 1) offers more than one interrupt > 2) will compile under msp430-gcc, in terminal > 3) is somewhat reliable as to hardware (the debouncing thing with > capacitors does not seem to work for me) > > I have mangled code to exhaustion, have been one full day and a couple > sleepless hours trying to figure this, and it's rather frustrating that > it doesn't seem anyone has had this issue before... The few code > examples are for some Windows-based tools. > > At some moment I found some values that I could replicate for pin 2, 3, > 4, 5, 7 (1 and 6 I had driving the LEDs to check if I was hitting > things), I was quite happy, but when testing the code again the next day > the values did not work anymore... The code got mangled, but what I > have I copy below. > > To complicate :-) I want to be enable to run the whatever from the OLPC > XO laptop - that means plain msp430-gcc and mspdebug on Fedora 17 > > Anybody has any idea where to? > > <yamarant> > Just as a BTW FYI, I wanted to keep working from my Ubuntu, and it > didn't. Trying to install msp430-gcc and mspdebug was PAINFUL. So I set > up a virtual machine with Fedora 17, and the sudo yum install went fine, > *except* for the include folder. BTW whatever I have under Ubuntu and > Fedora says that signal.h is deprecated, and all sorts of code in the > internet just won't compile - I figured out the pragma vc interrupt > thing, but it all feels downright silly, wasn't C supposed to be > somewhat /standard/?!?! And Linux standard times 8 square? (this is > payback, no doubt, the many times I made sly remarks about windowsware, > reffering to its minions as "people of non standard software" > </yamarant> > > It is marvelous that this works at all, no doubt, but I shudder when it > comes to offering this to kids even noober than I... > > BTW, this compiles perfect in the OLPC, msp430-gcc 3.2.3 > > #include <msp430x20x3.h> > #include <signal.h> > #include <stdint.h> > > #define RED BIT0 > #define GREEN BIT6 > #define BUTTON BIT4 > > int main(void) > { > WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer > P1DIR |= (RED + GREEN); // Set P1.0 to output direction > // P1.3 must stay at input > P1OUT &= ~(RED + GREEN); // set P1.0 to 0 (LED OFF) > > P1IE |= BUTTON; // P1.3 interrupt enabled > > P1IFG &= ~BUTTON; // P1.3 IFG cleared > //P1OUT ^= (RED + GREEN); > eint(); // enable all interrupts > for(;;) > {} > } > unsigned int i=0; > > // Port 1 interrupt service routine > interrupt(PORT1_VECTOR) PORT_1(void) > { > if (P1IFG > (176)) {P1OUT ^= (RED);}; // P1.0 = toggle > // if (P1IFG == (144)) {P1OUT ^= (GREEN);}; // 144 is pin 1.4 input > if (P1IFG > (178)) {P1OUT ^= (GREEN);}; // 136 is pin 1.3 input > // if (P1IFG == (132)) {P1OUT ^= (GREEN);}; // 132 is pin 1.2 input > // if (P1IFG == (130)) {P1OUT ^= (GREEN);}; // 130 is pin 1.1 input > // if (P1IFG == (144)) {P1OUT ^= (GREEN);}; // 144 is pin 1.4 input > for (i; i<200;i++); // P1.0 = toggle > P1OUT &= ~(RED + GREEN); // set P1.0 to 0 (LED OFF) > i = 0; > P1IFG = 0; // P1.3 IFG cleared > P1IES ^= BUTTON; // toggle the interrupt edge, > // the interrupt vector will be called > // when P1.3 goes from HitoLow as well as > // LowtoHigh > } > > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_sfd2d_oct > _______________________________________________ > Mspgcc-users mailing list > Mspgcc-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mspgcc-users ------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_sfd2d_oct _______________________________________________ Mspgcc-users mailing list Mspgcc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mspgcc-users