Jump to content


  • Content Count

  • Joined

  • Last visited

  1. So I have spent the last 8 hours trying to use NJC's code from his "Launchpad Example Project Ripped Open" post on his blog to send a single byte every time the user presses the p1.3 button. However, it never worked when I pressed the button. So I decided to test my understanding of Input interrupts with a simple LED toggle program based on P1 interrupts. Edit: I forgot to mention that I was using a LaunchPad. Fixed some spelling as well. What is weird is that this code only "sometimes" works. I download and debug in EW, allow it to run freely, and then press the button, and nothing happens. Other times it does. I just don't know what the deal is. I did notice that sometimes when I would press the button, the IF for some of the OTHER pins on P1 would go high, but not P1.3, which makes absolutely no sense. I tried configuring all the unused pins as outputs, which I should be doing anyway, but that didn't change anything. In short: I'm an idiot, the interrupt which is supposed to toggle the LEDs does not, do yall have any input? include #include #include #include #define BUTTON BIT3 #define LED1 BIT0 #define LED2 BIT6 void ledToggle(void); void main(void) { WDTCTL = WDTPW + WDTHOLD; BCSCTL1 = CALBC1_1MHZ; // Set range DCOCTL = CALDCO_1MHZ; // SMCLK = DCO = 1MHz P1DIR = 0xff; // set all pins to output P1OUT = LED2; // set LED2 on at first P1DIR &= ~BUTTON; //and Button in P1REN |= BUTTON; // enable pull-up resistor P1IES = BUTTON; // set to interrupt on high to low P1IFG = 0x00; // disable interrupt flag before enabling interrupt P1IE = BUTTON; // enable P1 on P1.3interrupt __bis_SR_register(GIE); // enable general interrupts LPM0; // start low power mode 0 } #pragma vector = PORT1_VECTOR __interrupt void Button_Press(void) { P1OUT ^= (LED2|LED1); // toggle LEDs P1IFG = 0x00; // clear P1IFGs }
  • Create New...