Dave Dribin wrote: > I've made some minor modifications to the code, like set p=16f877, > include "p16f877.inc", and add some debugging code to print the CRC > out the serial port when entering CRC16. In other words, nothing > that should affect the CRC. > > When I run the code through the simulator (gpsim under Linux), I get > correct results. The CRC matches the ones in the comments as I step > through the code. However, when run on a real PIC (16F877 @ 4MHz), > the results are wrong. Note: the results in comments appear to be > correct. I've verified it with some C code on the desktop. Here are > the results from a real PIC from the serial port Dave: Twenty dollars says that the CRC is being calculated correctly, but your serial-out routine (and whatever other junk you've put between the PIC's registers and your eyes) is corrupting the data that you see. -Andy P.S. In order to avoid using a temporary register, the author of your CRC code made it slow, large, and dangerously tricky. If you don't mind using one extra register, you could improve the code quite a bit. === Andrew Warren -- aiw@cypress.com === Principal Design Engineer === Cypress Semiconductor Corporation === === Opinions expressed above do not === necessarily represent those of === Cypress Semiconductor Corporation -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu