checksum == 0xFF?

Status
Not open for further replies.

butters

Member
checksum == 0xFF?, helps needed.

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:
Your pdf states that if you add together add+cmd+data+cksum it should equal 0xff.

Edit, for anyone confused, the pdf was in the OPs last thread.

Mike.
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…