mondo8205 0 Posted November 16, 2012 Share Posted November 16, 2012 Im trying to make the button work as an interrupt but pin 1.3 is 0V so the only way to accomplish the interrupt is to jumper 3.3V to that pin. I'm using an edge interrupt and the button takes pin 1.3 to ground but if pin 1.3 is already low it does nothing. How do I get pin 1.3 to be high and look for the low edge??? Here is some code I have written already, BUTTON is BIT3. WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer P2DIR |= (BIT0 + BIT1 + BIT2 + BIT3);//Set Port2.0.1.2.3 direction to output P2OUT &= ~(BIT0 + BIT1 + BIT2 + BIT3);//Set Port2.0.1.2.3 to all zero P1DIR |= (BIT0 + BIT1 + BIT2 + BIT4);//Set Port1.0.1.2.4 direction to output P1OUT &= ~(BIT0 + BIT1 + BIT2 + BIT4);//Set Port1.0.1.2.4 to all zero P1IE |= BUTTON;//Interrupt edge on Port 1.3 button P1REN |= BUTTON;//set internal pull up resistance for Port 1.3 Quote Link to post Share on other sites
RobG 1,892 Posted November 16, 2012 Share Posted November 16, 2012 Your P1.3 resistor is configured as pull-down. Try this: P1OUT |= BIT3; Also, clear IFG just in case and move P1IE to the end. Quote Link to post Share on other sites
cde 334 Posted November 16, 2012 Share Posted November 16, 2012 Bit 3 of P1Out needs to be set to 0 for pulldown, and 1 for pullup resistor, in addition to enabling that same bit in P1REN. Default is 0. Also, I just lost an auction on ebay while looking this up X( Quote Link to post Share on other sites
roadrunner84 466 Posted November 16, 2012 Share Posted November 16, 2012 P1REN will enable the resistor, which can be both pull-up and pull-down. Which of these two depends on P1OUT; would P1OUT make the output high, then it's pull-up, would it make P1OUT low, then it's a pull-down. Also (a mistake I made once), P1REN takes "priority" over P1DIR; set as output and resistor, will make it pull up/down, not drive high/low. I recommend you set P1REN first, then clear P1IFG and after that enable P1IE. This will prevent any unintended interrupts from occurring. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.