Searching \ for '[EE]: Checksum algorithm' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/method/errors.htm?key=checksum
Search entire site for: 'Checksum algorithm'.

Exact match. Not showing close matches.
PICList Thread
'[EE]: Checksum algorithm'
2003\03\26@050133 by Alan B. Pearce

face picon face
Being of the mathematically challenged variety, I was pondering this
question the other day, after having some problems with devising a checksum.

What is a good way of doing a checksum? The particular data I have contains
lots of 0x00 bytes, with a few interspersed non-zero bytes. I was wanting to
store these in an eeprom with a header of 8 bytes, and a checksum that my
initialisation routine could use to verify data integrity on power up, and
if necessary report an error message.

The header is to contain two 16 bit pointers, one to beginning of data,
other to end of data (actually checksum byte). If both are equal then there
is no actual data, and the checksum should be just the header checksum. The
beginning of data pointer should always point to location 8, once the eeprom
has been initially set-up, but it turned out the algorithm I was using still
reported a good checksum with the ex-factory contents of all zeros. :)) I
was using an add and shift algorithm I had come across on a serial line
protocol, but other details of that protocol meant it did not get lots of
zeros in the data because of compression within the protocol. On this basis
it looks like I chose an unsuitable checksum system for this purpose,
although now it is all installed and running it seems to serve the purpose
OK.

Does anyone have any pointers to suitable algorithms that those of us who
are challenged in these sort of mental mathematics can look at please? About
the only other method I could think of was to use a CRC type method, but I
was not looking to do anything quite that complex.

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spam_OUTlistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body

2003\03\26@051207 by Mike Harrison

flavicon
face
With data containing a lot of the same value, it is important that the checksum algorithm takes into
account the address of the data as well as the content, so a simple arithmetic sum is not suitable.
A simple enhancement  could be to XOR the data bytes with the address (or byte count) LSB before
adding. A simple CRC is not at all complicated to do if speed is not critical  - a handful of
instructions. If you're using a serial eeprom with bit-bashed access, it gets even easier as you add the CRC in
the read/write code in half a dozen instructions or less.

You don't need to understand the maths. If you're using the PIC 18 series, the multiply instruction
offers some useful possibilities as well.

On Wed, 26 Mar 2003 10:00:58 -0000, you wrote:

{Quote hidden}

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email .....listservKILLspamspam@spam@mitvma.mit.edu with SET PICList DIGEST in the body

2003\03\26@081853 by Alan B. Pearce

face picon face
Flaming Outspook Expletive mail program - did the same to Olin as it does to
me. :))


----- Original Message -----
From: "Alan B. Pearce" <A.B.PearcespamKILLspamRL.AC.UK>
To: <.....PICLISTKILLspamspam.....MITVMA.MIT.EDU>
Sent: Wednesday, March 26, 2003 1:06 PM
Subject: Re: Checksum algorithm


> OK Thanks Olin, that does look useful.
>
> It is very similar to what I was doing, but I initialised to 00 (which is
> probably where I made a major mistake as most of the data is 00,
especially
> on a new eeprom), and then did an 8 bit add/rotate. Adding the byte
> complement to the high byte of the 16 bits should also introduce enough
> change as well.
>
> --
> http://www.piclist.com#nomail Going offline? Don't AutoReply us!
> email EraseMElistservspam_OUTspamTakeThisOuTmitvma.mit.edu with SET PICList DIGEST in the body

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservspamspam_OUTmitvma.mit.edu with SET PICList DIGEST in the body

2003\03\26@084731 by Scott Dattalo

face
flavicon
face
On Wed, 26 Mar 2003, Alan B. Pearce wrote:

> Being of the mathematically challenged variety, I was pondering this
> question the other day, after having some problems with devising a checksum.
>
> What is a good way of doing a checksum? The particular data I have contains
> lots of 0x00 bytes, with a few interspersed non-zero bytes. I was wanting to
> store these in an eeprom with a header of 8 bytes, and a checksum that my
> initialisation routine could use to verify data integrity on power up, and
> if necessary report an error message.

<snip>

> Does anyone have any pointers to suitable algorithms that those of us who
> are challenged in these sort of mental mathematics can look at please? About
> the only other method I could think of was to use a CRC type method, but I
> was not looking to do anything quite that complex.

I'm not sure what you mean by too complex, but you may want to check out
this CRC algorithm:

http://www.dattalo.com/technical/software/pic/crc_1021.asm

It's an implementation of CRC-CCITT-16 and takes only 17 cycles per byte.

Scott

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email @spam@listservKILLspamspammitvma.mit.edu with SET PICList DIGEST in the body

2003\03\26@102021 by Olin Lathrop

face picon face
> Flaming Outspook Expletive mail program - did the same to Olin as it
> does to me. :))

Which was what?  It's bad enough to get screwed by the mail program, worse
to not even realize it.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email KILLspamlistservKILLspamspammitvma.mit.edu with SET PICList DIGEST in the body

2003\03\26@104510 by Alan B. Pearce

face picon face
>> Flaming Outspook Expletive mail program - did the same to Olin as it
>> does to me. :))
>
>Which was what?  It's bad enough to get screwed by the mail program,
>worse to not even realize it.

Oh it was your reply to my original post on this thread. Your reply had the
[EE]: chopped off it, as per the discussion recently on this list over it
happening with OE. I just replied to yours, without realising that this had
happened.

I only realised it had occurred when my reply was sent to me by the list as
I sort into different mailboxes according to the PICLIST Tag, and the
remainders go into a "leftovers box". I wasn't sure if you get the untagged
mails so resent with the tag and that comment.

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email RemoveMElistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body

More... (looser matching)
- Last day of these posts
- In 2003 , 2004 only
- Today
- New search...