我正在为MSP430微控制器编写嵌入式C代码,并且我被一个返回错误值的函数卡住了。当我使用debugger单步执行代码时,它显示函数应该返回1,但它在设置的int上返回0。
代码:
void sendUart(unsigned char string[], int length){
if(string != 0){
while(~responseAOK()){
int BLEstatus = BLEReadyForData(); **//Function called here**
if(BLEstatus){ **//At this point, BLEstatus is 0 (incorrect)
unsigned int i;
for(i=0;i<length-1;i++){
while(!(IFG2 & UCA0TXIFG));
UCA0TXBUF = string[i];
send[sendIndex] = string[i];
sendIndex++;
}
sendIndex = 0;
}
}
}
}
int BLEReadyForData(){
if(P2DIR & BIT3){
P2DIR &= ~BIT3;
}
if(P2IN & BIT3){
return 1; //debugger step-through reaches this line of code
}
else return 0;
}发布于 2019-11-14 22:08:32
您应该首先关闭优化。这使得单步调试变得令人困惑。例如,在IAR中
Project -> Options -> C/C++ Compiler -> Optimizations tab -> Level -> Nonehttps://stackoverflow.com/questions/55671793
复制相似问题