Я пишу встроенный код C для микроконтроллера MSP430, и я застрял в функции, возвращающей неправильное значение. Когда я перебираю код с помощью отладчика, он показывает, что функция должна возвращать 1, но она возвращает 0 в установленном int.
Код:
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;
}