Page 1 of 1

Calculating 8 bit checksum from a series of bytes?

Posted: Mon Nov 23, 2020 12:48 am
by tcbcats
I am doing some serial communication and need to calculate a 8 bit (one byte) checksum by adding up a series of 10 bytes.
I have been able to do it but when the checksum value goes over 255 is keeps counting up and ends up in a 16 bit value.
I need the 8 bit value to roll over from FF and keep the checksum result in a 8 bit value that just keeps rolling over to 00 when he count reaches FF.
I there a simple way to do this?

Re: Calculating 8 bit checksum from a series of bytes?

Posted: Mon Nov 23, 2020 4:40 am
by dunbarx
Hi,

Can you (pseudo)

Code: Select all

put checkSumValue mod 255 into checkSumValue
This will roll over, where 254 = 254, 255 = 0 and 256 = 1.

Craig

Re: Calculating 8 bit checksum from a series of bytes?

Posted: Tue Nov 24, 2020 9:02 pm
by tcbcats
Thanks it worked... had to set 255 to 256 in order the keep the correct count sequence.