c8051f040 コントローラーから 2 つのピンを読み取ろうとしています。
ポートを直接読み取ることはできますが、同じポート値を変数に保存すると、デバッガーが正しい値を表示しても機能しません。
// This works
if((P1 & 0xF0) == 0xa0)
{
YEL_LED = 1; //Turn on
}
else
{
YEL_LED = 0; //Turn off
}
// This does not work even though the debugger
// shows the correct value 0xa0 for the var
ORange = (P1 & 0xF0);
if(ORange == 0xa0)
{
YEL_LED = 1; //Turn on
}
else
{
YEL_LED = 0; //Turn off
}
これは KEIL c51 のバグですか、それとも最適化されているものですか。