Hello Group,
Can someone shed some light on why this code is broke,
I followed the users guide but I must be missing something.
I am working with the MSP430F1232.
Port P2.1 seems to work, I do hit the interrupt for both P2.1 and
P2.4 when both bottons are pushed but never enter the code below to
turn on the LED. I am using CrossStudio.
-- Thanks..
if(P2IFG &= 0x10){
LEDRED(ON);
P2IFG &= ~0x10; //Clear interrupt flag
}
Trying to set up falling edge interrupt.
init code below in main()
//pushbutton S1
P2DIR &= ~0x02; //P2.1 Input for interrupt
P2IES |= 0x02; //P2.1 interrupt edge high to low
P2IFG &= ~0x02; //Clear P2.1 interrupt flag
P2IE |= 0x02; //Enable P2.1 interrupts
//pushbutton S2
P2DIR &= ~0x10; //P2.4 Input for interrupt
P2IES |= 0x10; //P2.4 interrupt edge high to low
P2IFG &= ~0x10; //Clear P2.4 interrupt flag
P2IE |= 0x10; //Enable P2.4 interrupts
last thing I do in main is enable interrupts with
_EINT(); // Enable interrupts
interrupt handler
void port_2(void) __interrupt[PORT2_VECTOR]
{
_DINT();
/*
* This interrupt services two port pins.
* PORT PIN 2.1 is a pushbutton.
* PORT PIN 2.4 is a pushbutton
*/
// PORT PIN 2.1 PUSH BUTTON
if(P2IFG &= 0x02){
LEDGRN(ON);
P2IFG &= ~0x02; //Clear interrupt flag
}
// PORT PIN 2.4 PUSH BUTTON
if(P2IFG &= 0x10){
LEDRED(ON);
P2IFG &= ~0x10; //Clear interrupt flag
}
_EINT();
}