This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Comparing Register Values

Sirs,

I am trying to compare a register value to a hex code value as shown below:

if(P0 == 0xAA)
{
        P0 = 0x00;
}
else if(P0 == 0x00)
{
        P0 = 0xAA;
}

in my code, I have it declared as:

sfr P0     = 0x80;

and initialized as:

P0 = 0x00;

Currently, the value of P0 is 0x00. Unfortunately, it isn't entering the else if loop as I would expect (so my program isn't setting P0 to 0xAA). I'm guessing it's because I am handling a register value incorrectly or can't compare a register value to a hex code. I'm guessing it's probably a pretty simple fix or there is a better approach to this. Can you help me understand what I am doing incorrectly? Thanks!

0