Finally add 1 to the entire checksum word. Do this by XOR'ing each byte of the checksum register with 0xFF. Now take the two's complement of that word by inverting each byte (turn each one into a zero, and each zero into a one). When you are finished with the data block, you will have an 8 or 16 (or whatever) bit word which is the sum of all of the data modulo 2 to the length of the checksum. If you are using a 16 bit checksum, collect each successive pair of bytes into a 16 bit word and then add that word to the 16 bit register. If you are doing an 8 bit checksum, add successive bytes to the 8 bit register. Now add each data element to the checksum. Start by clearing the checksum register to zero. If you are being compatible with an existing standard, you must use the length called for by that standard. For convenience, the length is usually an integer multiple of 8 so that an integer number of bytes can be used to hold the checksum. Typically this would be either 8 or 16 bits, but any length is possible. First choose the length of the checksum that you want. If you are sure that a mere checksum is all that you want, than you generate it as follows. The CRC is more complex to generate, but provides better protection. Both of these perform the same function, which is to validate data and verify that it has not been corrupted in transmission or other handling. Thanksįirst, you must understand the difference between a checksum and a CRC (cyclic redundancy check). So if you sirken or anyone else could shed some light on this I would greatly appreciate it. I have read so many confilicting things and at this point Im not sure what to do. How exactly do you implement a checksum into your code. However Im looking for a more generic explanation. If you save it to program memory, then you might consider using the DT directive, or if you save it to data EE, use the DE directive. You should also exclude the locations where the checksum is saved from the checksum calculation. At any rate, if you add it all up, just save it to RAM and compare it against some value saved into data EE or saved as a table in program memory. Also, the processor does not have the capability to read its own configuration words, so the checksum that you obtain should not include the configuration word, nor the configuration ID. You will need to generate code to read the program memory and possibly the data EEPROM, then add it all up. The PIC16F877 doesn't do a checksum calculation on its own. In response to the questions you've posed: My user name is Santana484 The thread is checksum calculation. Please reply to the message board as my email account does currently work. For example.ġ) Once I obtain the checksum calculation from MPLAB's IDE where do I store it in the code for comparision later?Ģ)How does the Microchip itself perform the computation? How do I perform a check against the checksum value. I have looked at the checksum calculation on that data sheet sevral times however I guess my real question is. For historical purposes, here's a copy of what you sent:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |