Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/16/07 10:31
Modified:
  08/16/07 10:36

Read: times


 
#143329 - Pitfalls
Responding to: ???'s previous message
* simple addition scheme without carry
* XORing all bytes together


Both of these have one major downside (which can be easily removed, though):

What happens if your data and the checksum gets set too all zeros ? Both of the algorithms will indicate a correct checksum. The XOR algorithm will even indicate a correct checksum if the data gets set to all 0xFFs and the number of bytes is odd.

The addition is the better choice of the two, because one wrong bit in the data will most likely lead to more than one wrong bit in the checksum - unlike the XOR algorithm where one wrong data bit will lead to one wrong checksum bit.

To avoid the all-zeros scenario, define the checksum as
- (lsb of sum of data bytes),
NOT (lsb of sum of data bytes)

or something similar.

List of 19 messages in thread
TopicAuthorDate
Simple EEPROM checksumming            01/01/70 00:00      
   Pitfalls            01/01/70 00:00      
      a checksum out of 2 bytes?            01/01/70 00:00      
         It's an "either - or" ...            01/01/70 00:00      
            code sketch            01/01/70 00:00      
               a simple checksum            01/01/70 00:00      
                  CRC8 instead of CR32            01/01/70 00:00      
                     I am talking about CRC-16 not CRC-8            01/01/70 00:00      
                        oups            01/01/70 00:00      
   how much data?            01/01/70 00:00      
      approx 40-60 bytes            01/01/70 00:00      
      I use 2 copies and a counter for that            01/01/70 00:00      
         adding to Jan's post            01/01/70 00:00      
   Here's one method            01/01/70 00:00      
      another interesting scheme!            01/01/70 00:00      
   Try the Dallas 1-wire CRC            01/01/70 00:00      
      another good idea but...            01/01/70 00:00      
         I just meant the CRC            01/01/70 00:00      
            oups            01/01/70 00:00      

Back to Subject List