Jump to content
43oh

Recommended Posts

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

Link to post
Share on other sites

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.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...