ON 20031031@3:03:55 PM at page: http://techref.massmind.orgscenix/lib/io/osi2/crc16ca_sx.htm JMN-EFP-786 James Newton published post 37925.3133449074 elkin.gonzalez@latinmail.com asks:
Hello,|Delete 'P-' before: '' but after: '
I've tried the code shown above for the PIC micro (on a 16F877A and 16F84A targets). The simulation with the MPLAB software works fine but when I try to run this code on any of the target processors the results are quite different (don't work).
For example, at the initial stage I load crc_hi and crc_lo registers with 0xFF the buffer pattern is: 02-01-01-00-10-03 (all in HEX) and when I update the CRC calculation with all the bytes contained at the buffer including the last one, I xor the final result with 0xFF, so the result must be crc_hi=8F, crc_lo= FB. This works fine in MPLAB but, when I run this code in the PICmicro I found that the results given are crc_hi=8E, crc_lo=3B. The results are wrong!
Pseudo code for the above:
crc_hi = crc_lo = 0xFF;
update crc for all buffer bytes;
crc_hi = crc_hi XOR 0xFF;
crc_lo = crc_lo XOR 0xFF;
Even more, using the same target processors and a different buffer for the CRC calculation (01-04-01-01-10-03) the resulting CRC is: crc_hi=12, crc_lo=08. This works fine on the MPLAB IDE and when I run this code on the PIC micro runs OK too!! With this pattern the code works!
So, the question is, why the code runs fine on the MPLAB IDE for all tests made and for all patterns and why not on the PICmicro? any initial missconfiguration or something like that?
I hope anybody can help me solving this trouble!!
Regards,
Elkin.