This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/MSP430F5529: Not getting GPIO interrupt for button press

Part Number: MSP430F5529

Tool/software: Code Composer Studio

Hi,

I am trying to toggle an LED on the MSP430F5529 Launchpad when a button is pressed. The button is on board the chip, connected to P1.1, and the LED is connected to 1.0.

I am not getting an interrupt for the button press.

My code is shown below. Can you tell me what is wrong?

#include <msp430.h> 


/**
 * main.c
 */
int main(void)
{
	WDTCTL = WDTPW | WDTHOLD;	// stop watchdog timer
	
	//Switch LED off
	P1DIR |= BIT0;    // P1.0 is output and the rest are input
	P1OUT &= ~0x01;
	P1IE  |= (BIT1);
	P1IES &= (~BIT1); // Falling Edge 1 -> 0
	P1IFG &= (~BIT1); // Clear interrupt flag for P2.1

	while (1)
    {
        __bis_SR_register(LPM0_bits + GIE);   // Enter LPM0 and wait for an interrupt
        __no_operation();                     // Set breakpoint >>here<< and read
    }

	return 0;
}

#pragma vector = PORT1_VECTOR
__interrupt void InterruptVectorPort1()
{
    P1OUT ^= 0x01;  // Toggle P1.0
    P1IFG &= ~BIT1; // Clear Interrupt Flag
}

  • turn on the pull up for P1.1
  • I tried that:

    #include <msp430.h> 
    
    
    /**
     * main.c
     */
    int main(void)
    {
    	WDTCTL = WDTPW | WDTHOLD;	// stop watchdog timer
    	
    	//Switch LED off
    	P1DIR |= BIT0;    // P1.0 is output and the rest are input
    	P1OUT &= ~0x01;
    	P1IE  |= (BIT1);
    	P1IES &= (~BIT1); // Falling Edge 1 -> 0
    	P1IFG &= (~BIT1); // Clear interrupt flag for P2.1
    	P1REN |= BIT1;
    
    	while (1)
        {
            __bis_SR_register(LPM0_bits + GIE);   // Enter LPM0 and wait for an interrupt
            __no_operation();                     // Set breakpoint >>here<< and read
        }
    
    	return 0;
    }
    
    #pragma vector = PORT1_VECTOR
    __interrupt void InterruptVectorPort1()
    {
        P1OUT ^= 0x01;  // Toggle P1.0
        P1IFG &= ~BIT1; // Clear Interrupt Flag
    }

    but I still don't get an interrupt.

  • How do you know you're not getting an interrupt?
    A debugger breakpoint in the ISR is a reliable indicator. The LED is less so, due to switch bounce. A breakpoint at the __no_operation() in main will never be reached (see also LPM0_EXIT).
  • I already have a breakpoint in my ISR and the debugger never gets there.

    Are there any jumpers I need to remove?
  • Your code acts as expected -- I hit a breakpoint in the ISR, and the LED responds (modulo switch bounce) -- on my F5529 Launchpad.

    [LP Rev 1.6. All the "eZ-FET" jumpers are installed except 5V, RTS, and CTS. JP8 (LED1) jumper is installed. Nothing else is connected. CCS 6.2.0.]

    If you Pause (double vertical bars in the toolbar), where is it executing?
  • ..and then I power cycled it, and saw your symptom. Add the line:

    P1OUT |= BIT1; // Pull Up, not Down

**Attention** This is a public forum