Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

Test P2IN Push Button -- fails

$
0
0

I moved code that was working fine from one MSP processor to another.  The code tests 2 ports to see if they are high or low to see if push buttons are pressed (hold low)?

The ports I am using are for the crystal, and I know that sometimes there are tricks to get these ports to work?  I did not see anything in the errata about this.  I attempted moving the ports, but I ran into other issues :-/

Product: MSP430G2553

Ports: P2.6 and P2.7 (either set up as input or output same results)

P2REN = 0xC0;// pulled-up

P2OUT= 0xC0;// high

P2SEL = P2SEL2 = 0x00:

I set break points and see that when the buttons are not pressed, P2IN is high for both ports, by pressing each button, the respective P2IN goes low.

I put in the following tests, and the behavior is erratic.

if(P2IN & BIT6) //P2.6 High = true

if(P2IN & BIT7) //P2.7 High = true

if( !(P2IN & BIT6)) //P2.6 Low = true

if(  !(P2IN & BIT7)) //P2.7 Low = true

In the end, I am combining the above tests for the two ports, example:  if( !(P2IN & BIT6)  &&  (P2IN & BIT7))// P2.6 low & P2.7 high?

I attempted to use logical AND (&&) and the negator (~) without success. 

Any suggestions or ideas out there?


Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>