vendredi 24 juin 2016

Statements on "if" not followed

I´m doing a little programming on C with a dsPIC, I have found a little tiny problem that I don´t know why or how is it happenning. Compiler C30 for MPLAB

I have this code:

int Function1(){
.
.
.
while(1){
.
.
.
P1 = EPC96_1[18];  //Here the value of P1 = 0xB6
P2 = EPC96_1[19];
CRC_CCITT(EPC96_2, 18);   //in this function CRC_1 is calculated also CRC2
if(P1 != CRC_1){       //In the calculation of CRC_1 it comes always 0xB6
  P1++;                //Both values P1 and CRC1 are the same, stil it 
  if(P2 != CRC_2)      //comes here and continues with the break
    break;
  }
}
return 1;
}
//end of my function, return to main code

----Sorry, I didn´t specify, it supose not to come into the if, the != is supose to be like that, because what I want the program to do is when both variables are equal, it should return to the while(1) start. I looked up for the variables on the Watch of the MPLAB (8.92) and they are the same. I do not think the problem is in the code before or after or in any other place, but I could be wrong. Has anybody found the same problem during your experience time?

Thank you for your time.

Aucun commentaire:

Enregistrer un commentaire