Part Number:MSP430F5529
Tool/software: Code Composer Studio
I'm having a hard time with a pretty basic problem. I've going through the user guides and examples but I can't figure out how to fix my problem. I have a GPIO pin on an MSP430F5529 configured as an input, and when the input is low, the outputs change. I want the outputs to change when the signal goes high. Here are the configurations:
P2DIR &= ~BIT5; // reset signal hardware interrupt P2OUT |= BIT5; // internal resistor pull up P2REN |= BIT5; // resistor enable P2IES |= BIT5; // interrupt edge select, 1 = high to low, 0 = low to high //P2IFG &= ~BIT5; //P2IE |= BIT5; // interrupt enable
#define EXT_INPUT P2IN & BIT5
and I have a function that controls the outputs based on this reading here:
if(EXT_INPUT){ //JP7 pin 4 will be used as the trigger input if (event == DETECTED) { if(consecpass++ > 2) //if there are three or more passes indicate there is a sample by turning green on and red off { GREEN_LED_ON; RED_LED_OFF; consecfail=0; } } if (event==NOT_DETECTED){ if(consecfail++ > 3 && consecfail < 35) { RED_LED_OFF; GREEN_LED_ON; consecpass=0; } if(consecfail > 35){ RED_LED_ON; GREEN_LED_OFF; } } if (consecpass>30000) //used to prevent roll over and to indicate failure if device is standing still. { consecpass=3; } if(consecfail>30000) //used to prevent roll over and to indicate failure if device is standing still. { consecfail=3; } }else{ consecpass=0; consecfail=0; RED_LED_ON; GREEN_LED_ON; }
I tried changing EXT_INPUT definition to ~BIT5, which kept the outputs in the if condition regardless of input. When I have if(EXT_INPUT==0) or ==1, the device stays in the else condition. What am I doing wrong?