checksum == 0xFF?, helps needed.
why the checksum == 0xff when the total itself is 0xFF?
my requirement of a checksum is 0xFF - (add+cmd+data) = checksum..
Code:
char GetByte(){
while(!DataRdyUSART());
return(getcUSART());
}
while(GetByte()!=0xce); //wait for header byte
checksum=0xce; //initialise checksum
for(i=0;i<4;i++){ //now get next 4 bytes
c[i]=GetByte();
checksum+=c[i];
}
if(checksum==0xff){
//got a valid package so send acknowledge
//and use the data
}
why the checksum == 0xff when the total itself is 0xFF?
my requirement of a checksum is 0xFF - (add+cmd+data) = checksum..
Last edited: