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!
Reading the register was more trouble than it was worth. I changed the code to:
Initialization:
bit CodeLocked = 0
Running Code:
if(CodeLocked==0) { P0 = 0xAA; CodeLocked = 1; } else if(CodeLocked==1) { P0 = 0x00; CodeLocked = 0; }
Thank you for your help!