Jump to content
43oh

Bug with PxOUT + INPUT_PULLUP?


Recommended Posts

I was trying a code that toggles a LED when i press a button. So i used P1OUT^=00000001; just toggle the output state of P1_0 right?

Well when i use that the push button stops working. I don't know why but it seems the pin just stays LOW always.

Is this command overriding the PinMode command?

 

I'm not sure but after P1REN is used you can control the pins with the pull ups/down enabled with P1OUT wich choses if it is pullup or down.

But with P1OUT^=00000001; should not change the bit 3

 

 

Used this code to test the state of the pin:

    boolean estado=digitalRead(P1_3);
    Serial.println(estado);
    if (digitalRead(P1_3)==LOW){
     //  P1OUT ^= 00000011;  
       delay(1);
     while(digitalRead(P1_3)==LOW){
       estado=digitalRead(P1_3);
       Serial.println(estado);
     }
    }
  }

First i enabled the P1OUT line. The serial said that the pin was always 0. The voltmeter confirms that

Then i disabled it. The pin is only 0 while it's pressed. The voltmeter also confirms that.

 

Is this normal?

Link to post
Share on other sites

What you are describing (flipping BIT0 only) does not agree w/ your code.

 

I assume it's the line you commented out that's offending.

 

i.e

 

P1OUT ^= 00000011;

 

This is not binary but decimal. The device sees it in hex as 0x0b or binary as 0b00001011.

 

This would toggle the bits 0, 1 and 3 which would upset your button.

 

Or did you paste your actual code accurately?

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...