我正在尝试从c8051f040控制器读取两个引脚。
直接读取端口有效,但是即使调试器显示正确的值,将相同的端口值保存到变量也不起作用。
// 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错误,或者是一些正在优化的东西。
发布于 2015-03-25 01:59:51
变量被声明为带符号的char。它应该是未签名的。
我被调试器愚弄了,调试器将监视变量显示为无符号。
https://stackoverflow.com/questions/29216344
复制相似问题