我正在为 LPC2148 使用 NEX 机器人板。我发现下面的代码行有一个非常奇怪的问题。
//Prototypes
void diaplayInRow1WithPosition(unsigned char* data, unsigned char position);
void diaplayInRow2WithPosition(unsigned char* data, unsigned char position);
unsigned char convertHigherNibbleToASCIIValue(unsigned char data);
unsigned char convertLowerNibbleToASCIIValue(unsigned char data);
int main (void)
{
unsigned char temp2;
unsigned int PLLStatus;
initializeAll();
PLLStatus = PLL0STAT;
temp2 = convertLowerNibbleToASCIIValue(PLLStatus);
diaplayInRow1WithPosition(&temp2,15);
temp2 = convertHigherNibbleToASCIIValue(PLLStatus);
diaplayInRow1WithPosition(&temp2,14);
temp2 = PLLStatus>>8;
temp2 = convertLowerNibbleToASCIIValue(PLLStatus);
diaplayInRow1WithPosition(&temp2,13);
return(0);
}
执行此代码时,我看到一个空白显示。我注意到问题出在最后一个 convertLowerNibbleToASCIIValue 函数调用上。它应该是:
temp2 = convertLowerNibbleToASCIIValue(temp2 );
但是由于这一行错误,为什么整个显示都是空白的?只有最后一个函数 diaplayInRow1WithPosition 应该有麻烦吧?即使更改了上面的行,我也得到了空白显示。所以我将包含最后一个 convertLowerNibbleToASCIIValue 的那行替换为
temp2 = convertLowerNibbleToASCIIValue(PLLStatus>>8);
最后我得到了正确的显示。
无法消化问题。任何人都可以帮忙吗?我需要的主要答案是,如果一行有问题,为什么前面的行没有正确执行?我正在使用 Keil 编译器和任何编译器依赖项?没有编译错误。如果类型等有问题,整个程序会损坏吗?