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.

MSP430G2553: Pin change Interrupt on P2.3

Part Number: MSP430G2553


Hello,

I am using MSP430G2553, specifically MSP430G2253IPW28 - TSSOP28 pin package.

The problem I am facing is with a button connected to the Pin P2.3.

There is no external pull-up on this pin only an internal Pull-up enabled upon configuration.

The program has a the PORT2_VECTOR configured.

But there is no interrupt break point hit.

There is an LED connected at Pin P1.0 in Active High configuration to indicate the occurrence of the interrupt.

Here is the snippet of the main I am trying to execute:

// P1.0 LED Active High/Low
// P2.3 Button Input with Pull-up

#include <msp430.h>

int main(void)
{
  WDTCTL = WDTPW + WDTHOLD;                 // Stop watchdog timer

  BCSCTL1 = CALBC1_1MHZ;                    //set range for the O.
  DCOCTL  = CALDCO_1MHZ;                    //set DCO step  modulation 1MHZ

  P1DIR = 0x01;                             // P1.0 output, else input
  P1OUT =  0x0;                             // P1.0 LED Off

  P2DIR &= ~BIT3;                           // P2.3 Input
  P2REN |= BIT3;                            // P2.3 pullup
  P2SEL &=~BIT3;
  P2SEL2&=~BIT3;
  P2OUT |= BIT3;                            // P2.3 set

  __disable_interrupt();
  P2IES |= BIT3;                            // P2.3 Hi/lo edge
  P2IFG &= ~BIT3;                           // P2.3 IFG cleared
  P2IE |= BIT3;                             // P2.3 interrupt enabled

  while(1)
  //__bis_SR_register(LPM4_bits + GIE);       // Enter LPM4 w/interrupt
      __bis_SR_register(GIE);
}

// Port 2 interrupt service routine
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=PORT2_VECTOR
__interrupt void Port_2(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(PORT2_VECTOR))) Port_2 (void)
#else
#error Compiler not supported!
#endif
{
  P1OUT ^= 0x01;                            // P1.0 = toggle
  P2IFG &= ~BIT3;                           // P2.3 IFG cleared
}

I would like to know if there is any mistake in the initialisation or configuration for P2.3.

Regards,

Ab

  • Hi,

    It does not look like your code was included. Please use the "Insert code using syntaxHighlighter" button to paste your code with the correct formatting. Then I take a look to see if there are any issues with your configuration.

    Regards,
    Nathan
  • Adding Missing Code

    // P1.0 LED Active High/Low
    // P2.3 Button Input with Pull-up
    
    #include <msp430.h>
    
    int main(void)
    {
      WDTCTL = WDTPW + WDTHOLD;                 // Stop watchdog timer
    
      BCSCTL1 = CALBC1_1MHZ;                    //set range for the O.
      DCOCTL  = CALDCO_1MHZ;                    //set DCO step  modulation 1MHZ
    
      P1DIR = 0x01;                             // P1.0 output, else input
      P1OUT =  0x0;                             // P1.0 LED Off
    
      P2DIR &= ~BIT3;                           // P2.3 Input
      P2REN |= BIT3;                            // P2.3 pullup
      P2SEL &=~BIT3;
      P2SEL2&=~BIT3;
      P2OUT |= BIT3;                            // P2.3 set
    
      __disable_interrupt();
      P2IES |= BIT3;                            // P2.3 Hi/lo edge
      P2IFG &= ~BIT3;                           // P2.3 IFG cleared
      P2IE |= BIT3;                             // P2.3 interrupt enabled
    
      while(1)
      //__bis_SR_register(LPM4_bits + GIE);       // Enter LPM4 w/interrupt
          __bis_SR_register(GIE);
    }
    
    // Port 2 interrupt service routine
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=PORT2_VECTOR
    __interrupt void Port_2(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(PORT2_VECTOR))) Port_2 (void)
    #else
    #error Compiler not supported!
    #endif
    {
      P1OUT ^= 0x01;                            // P1.0 = toggle
      P2IFG &= ~BIT3;                           // P2.3 IFG cleared
    }
    
    

  • Hello, Please have a look at the Code posted. Earlier due to some issue while posting the code was not showing up. Regards, Ab
  • I put this on a (G2) Launchpad and jumpered P1.3 to P2.3, and the LED lights when I push the (P1.3) button.

    How is your button wired?
  • P2.3 is directly connected to button. On the other side of the button there is ground. No pull-up on P2.3.
    P2.3 -(Button)-GND
  • Also on the Launch Pad with the PDIP-28 pin version its working. But with TSSOP-28 package its not working.
  • The (Rev 1.5) Launchpad also doesn't have a pullup on P1.3 (R34 is absent on mine), so I expect the internal one is adequate.

    Can you see P2IN.3 go low when you push the button?
  • Yes, Both on the actual PCB and the Launch pad the measured voltage reaches 0 upon pressing the button.
    The interesting part is that the voltage swing from 3.2V to 0V is observed on both cases. But only on Launch pad it works. On our PCB there are no components between the button and the chip. Its a direct connection. Another possibility is that the P2.3 might be damaged on the Chip. We would test that by trying an output to an LED to check the Level on the pin.
  • The problem got solved finally. There was a minor shot wire between P3.4 and P2.3 that was causing the level change. Once we de-soldered the chip and removed the short underneath the chip the code just worked fine. Thank you everyone for the help.

**Attention** This is a public forum