Other Parts Discussed in Thread: MSP-EXP430F5529LP
I am trying to write a basic interrupt code using interrupts from Button S2 (Port 1.1) to toggle LED1 (Port P1.0).
I have gotten polling to register button presses but my interrupt code does not appear to be working. Specifically, using the debugger, it appears the code is not passing the __bis_SR_register(GIE) statement.
Does anyone know why this code is not working to use interrupts to toggle an LED?
My code is:
#include <msp430f5529.h> #define RED_LED BIT0 #define BUTTON BIT1 int main() { P1DIR |= RED_LED; P1OUT &= ~RED_LED; // Set as input pin P1DIR &= ~BUTTON; // Set pullup resistor P1REN |= BUTTON; P1OUT |= BUTTON; // Interrupt Edge Select P1IES &= ~BUTTON; // Clear Interrupt Flag P1IFG &= ~BUTTON; // Set as interrupt pin P1IE |= BUTTON; __bis_SR_register(GIE); while(1) { } } #pragma vector=PORT1_VECTOR __interrupt void port1_isr(void) { P1OUT ^= RED_LED; P1IFG &= ~BUTTON; }