Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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.

Latest threads

New Articles From Microcontroller Tips

Back
Top