Andy2k7
Newbie level 3
OK im doing a uni project where im connecting up a keypad to the MSP430. I have all the rest of my code sorted out but what im struggling with is a way to have my interrupt only trigger on either a rising or falling edge not on both. That's my code below but like I said when P1.4 goes high the LED's come on but when I let go off the button they go off.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 #include "io430.h" #define LED0 BIT0 #define LED1 BIT6 void main( void ) { // Stop watchdog timer to prevent time out reset WDTCTL = WDTPW + WDTHOLD; P1DIR |= (LED0 + LED1); P1OUT &= ~(LED0 + LED1); P1IE |= BIT4; P1IFG &= ~BIT4; __enable_interrupt(); while(1) { } } #pragma vector=PORT1_VECTOR __interrupt void Port_1(void) { P1OUT ^= (LED0 + LED1); // P1.0 = toggle P1IFG &= ~BIT4; // P1.4 IFG cleared P1IES ^= BIT4; // toggle the interrupt edge, }
Last edited: