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

C51 compiler buggy behaviour?

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