>-----Original Message----- >From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] >Sent: 29 June 2006 00:24 >To: PICLIST Post >Subject: [PIC] CRC > > >All, > > I have wasted way too much time so I am hoping that someone >on the list can help me. > > I have an application that utilizes the serial port for >sending and receiving either very short (4 byte) packets or >long (1000 byte) packets. I have been requested to implement >CRC to the data packets. The problem I am having is that every >CRC program I have been able to find provides a different >answer for the same conditions. One site claims that their >implementation is correct and another states that theirs is >correct. Since the CRC will either be checked or generated by >a separate program on the PC I need to be reasonably sure that >what I have implemented is correct and repeatable. > > A 2 byte overhead for a 4 byte packet seems excessive so I >thought of using CRC8. But will CRC8 be sufficient for a 1000 >byte packet? > > Can anyone point me to (or provide me with) some source code >that implements the CRC generation/checking (either table driven or >algorithm) in "C" please since I have been asked to limit my >use of assembly since it makes it more difficult for them to >maintain in the future. For what ever difference it makes, I >am working with the PIC24. I'm suffering from the same problems. I am supposed to be using the CCITT CRC16, but there seem to be some aspects of the algorithm that aren't clearly defined, so you end up with various implementations that give different results. The guy who wrote this web page http://www.joegeluso.com/software/articles/ccitt.htm is convinced his algorithm is the correct one, but YMMV. The problems only really start if you have to interface to a system outside your control, where you need to know the exact algorithm used. If you are writing software for both sides of a link the exact implementation does not matter quite so much as long as they are the same. Some interesting background in this document: http://www.ece.cmu.edu/~koopman/roses/dsn04/koopman04_crc_poly_embedded.pdf Regards Mike ======================================================================= This e-mail is intended for the person it is addressed to only. The information contained in it may be confidential and/or protected by law. If you are not the intended recipient of this message, you must not make any use of this information, or copy or show it to any person. Please contact us immediately to tell us that you have received this e-mail, and return the original to us. Any use, forwarding, printing or copying of this message is strictly prohibited. No part of this message can be considered a request for goods or services. ======================================================================= -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist