Part Number:MSP430FR2311
Tool/software: Code Composer Studio
I am trying to setup an interrupt to fire on a falling edge transition on P2.2. For testing, I started with the msp430fr231x_P1_03 example code which works to trigger an interrupt from P1.3 and copied the settings to P2.2. I have checked in the debugger that the P2IN register is changing when the button is pressed. I also have tried setting the P2IFG from software which was successful in triggering the P2 interrupt. The issue is that when the button is pressed, the P2IFG register is not set.
Where am I going wrong? This should be a pretty simple thing to do.
#include <msp430.h> int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer // Configure GPIO P1OUT &= ~BIT0; // Clear P1.0 output latch for a defined power-on state P1DIR |= BIT0; // Set P1.0 to output direction P1OUT |= BIT3; // Configure P1.3 as pulled-up P1REN |= BIT3; // P1.3 pull-up register enable P1IES |= BIT3; // P1.3 Hi/Low edge P1IE |= BIT3; // P1.3 interrupt enabled P2OUT |= BIT2; P2REN |= BIT2; P2IES |= BIT2; P2IE |= BIT2; // Disable the GPIO power-on default high-impedance mode // to activate previously configured port settings PM5CTL0 &= ~LOCKLPM5; P1IFG &= ~BIT3; // P1.3 IFG cleared P2IFG &= ~BIT2; while(1) { __bis_SR_register(LPM3_bits | GIE); // Enter LPM3 w/interrupt __no_operation(); // For debug P1OUT ^= BIT0; // P1.0 = toggle } } // 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 &= ~BIT3; // Clear P1.3 IFG //P2IFG |= BIT2; // test to see if interrupt triggers from software __bic_SR_register_on_exit(LPM3_bits); // Exit LPM3 } #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__) #pragma vector=PORT2_VECTOR __interrupt void Port_2(void) #elif defined(__GNUC__) void __attribute__ ((interrupt(PORT1_VECTOR))) Port_1 (void) #else #error Compiler not supported! #endif { P2IFG &= ~BIT2; // Clear P2.2 IFG __bic_SR_register_on_exit(LPM3_bits); // Exit LPM3 }