Hi,
I am trying to read two pins from a c8051f040 controller.
Reading the port directly works , but saving the same port value on a variable does not work even though the debugger shows the correct value.
if((P1 & 0xF0) == 0xa0) // This works { YEL_LED = 1; //Turn on } else{ YEL_LED = 0; //Turn off } ORange = (P1 & 0xF0); // this does not work even though the debugger shows the correct value 0xa0 for the var , the led stays always off if(ORange == 0xa0) { YEL_LED = 1; //Turn on } else{ YEL_LED = 0; //Turn off }
is this standard behavior or a bug
You neglected to tell us hat ORange is!
Why? It is very important in determining what is going wrong. All we can do is guess, and my guess is that you have given it an incorrect signage.
That was the issue. It was supposed to be unsigned but I declared it as char which is signed.
Thanks for coming back. So many people don't.
Good to hear that you've got your problem sorted.