I loaded an example for the 5529 that blinks an LED every time a pin interrupt is detected. I modified the code to use a user button instead of an empty GPIO (P1.4) pin for the dev board (P1.1). Before I commented out the interrupt enable and disable in the main and ISR respectively, the program would, with low consistency, operate correctly. I removed both lines and the program executes perfectly. Could someone explain how this works? Thanks.
#include <msp430.h> int main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer P1DIR |= BIT0; // Set P1.0 to output direction P1OUT &= ~BIT0; P1REN |= BIT1; // Enable P1.4 internal resistance P1OUT |= BIT1; // Set P1.4 as pull-Up resistance P1IES &= ~BIT1; // P1.4 Lo/Hi edge P1IFG &= ~BIT1; // P1.4 IFG cleared P1IE |= BIT1; // P1.4 interrupt enabled while(1) { __bis_SR_register(LPM0_bits + GIE); // Enter LPM4 w/interrupt __no_operation(); // For debugger P1OUT ^= BIT0; // P1.0 = toggle // P1IES ^= BIT1; // Toggle between H-L and L-H transition triggers // P1IE |= BIT1; // Enable port interrupt } } // Port 1 interrupt service routine #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__) #pragma vector=PORT1_VECTOR __interrupt void Port_1(void) #elif defined(__GNUC__) void __attribute__ ((interrupt(PORT1_VECTOR))) Port_1 (void) #else #error Compiler not supported! #endif { P1IFG &= ~BIT1; // Clear P1.4 IFG // P1IE &= ~ BIT1; // Clear P1.4 IE __bic_SR_register_on_exit(LPM0_bits); // Exit LPM4 }