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.

Interrupt addition button MSP430FG4618

Other Parts Discussed in Thread: MSP430FG4618

Hello all.

I connect 1 additional button to port 1 in MSP430FG4618. The button normally open.

i want each press on button, toggle LED on port 2.2. The problem that the build in buttons (the two red buttons)  work good . if i press new button on P1.2 for example it toggle the led but if i come back and press on the build in buttons (the two red buttons) they don't work and only button connected to P1.2 continue to toggle if i press it.  
I want to accent that i connect the button without resistor but i don't think that is the problem because new button works good separately.

i will be greatful If anyone can help .

#include <msp430xG46x.h> // Library
#include <LCD_defs.h> // Library


#pragma vector=PORT1_VECTOR
__interrupt void Port_1 (void)
{
volatile unsigned int i;

/////////////////////////////////////////////////////////////////////////(S1)
if( P1IFG & 0x01 )
{

P2OUT ^= 0x04; //Toggle Port P2.2
i=1500; //Delay, button debounce
do (i--);
while (i !=0);

while (! (P1IN & 0x01)); //Wait for the release of the button

i=1500; //Delay, button debounce
do (i--);
while (i !=0);

P1IFG &= 0x00; //Clean P1.0 Interrupt Flag
}

/////////////////////////////////////////////////////////////////////////(S2)
if( P1IFG & 0x02 )
{

P2OUT ^= 0x04; //Toggle Port P2.2
i=1500; //Delay, button debounce
do (i--);
while (i !=0);

while (! (P1IN & 0x02)); //Wait for the release of the button

i=1500; //Delay, button debounce
do (i--);
while (i !=0);

P1IFG &= 0x00; //Clean P1.1 Interrupt Flag
}

//////////////////////////////////////////////////////////////////////////(3)
if( P1IFG & 0x04 )
{

P2OUT ^= 0x04; //Toggle Port P2.2
i=1500; //Delay, button debounce
do (i--);
while (i !=0);

while (! (P1IN & 0x04)); //Wait for the release of the button

i=1500; //Delay, button debounce
do (i--);
while (i !=0);

P1IFG &= 0x00; //Clean P1.2 Interrupt Flag
}

}

void main (void)
{
WDTCTL = WDTPW | WDTHOLD; //Stop Watchdog Timer

P1SEL &= 0x00;
P2DIR |= 0x04; //Configure P2.2 as Output (LED1)
P1DIR &= ~0xFF; //Configure P1 as Input (S1)
P1IE |= 0xFF; //Interrupt Enable in P1
P1IES |= 0xFF; //P1 Interrupt flag high-to-low transition


_BIS_SR (LPM3_bits + GIE); //Low Power Mode with interrupts enabled
}

 

  • Michael Mishka said:
    I want to accent that i connect the button without resistor but i don't think that is the problem because new button works good separately.

    What do you mean with 'separately'?

    The reason for th epullup resistors (external or internal ones, if available on the MSP), is to pult heline into the opposite direction when the button is not pressed. If it is missing, line capacitance and leakage currents may cause the line to be detected permanently low, whether you release the button or not.
    Attaching a multimeter or even a scope will change the behaviour (we're talking about pF and nA here)

  • Thanks. You right !

    I connect resistors of 100K and now all the new buttons work very well. 

**Attention** This is a public forum