Hello, I have a sqr waves going into a pin of my MSP430G2553, the sqr wave is HIGH for ~120 microseconds then LOW for the same amount of time. I am trying to set up an interrupt to read 7 digital inputs when the interrupt is triggered, Low-to-high. When the interrupt happens I want to check in the value in PORT1 P1IN equals a certain binary or hex number, if that is the case then i want to toggle an LED.
My problem is that whenever I connect the sqr wave into the pin, the LED seems to always be on. I am not sure if the interrupt is happening.
#include <msp430.h> volatile int digit1; volatile char value; void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer P1DIR =0; // Set set all pins as inputs. P2DIR = 0XF9; // set P2.1 AND P2.2 as inputs for the sqr wave P2OUT = BIT4; // LED starts as "on" P2REN = BIT2; // pullup P2IE |= BIT2; // P2.2 interrupt enabled P2IES |= BIT2; // P2.2 Hi/lo edge P2IFG &= ~BIT2; // P2.2 IFG cleared _BIS_SR(LPM4_bits + GIE); // Enter LPM4 w/interrupt } // Port 1 interrupt service routine #pragma vector=PORT2_VECTOR __interrupt void Port_2(void) { value=P1IN; if(value == 0x40){digit1=0;} if(value == 0x79){digit1=1;} if(value == 0x24){digit1=2; P2OUT ^=BIT4; } //if the value of P1IN is 0x24 or 00100100 //which corresponds to "2" in a 7 segments LED display then toggle LED. P2IFG &= ~BIT2; // P2.2 IFG cleared }
Maybe my LED is actually toggling but its too fast to notice?
In addition im pretty new to MSP430 and embedded programming, please excuse any silly mistakes.