Dear friends, I'm trying to develop a CRC-32 routine for my V-Star Quisar 320 using the Keil C51 compiler suite. I have found (in the Internet) a sample C code implementing CRC-32 algorithm. Testing this code in Turbo C (for DOS) and in Visual Basic (after the addequate porting), it runs perfectly. The same Turbo C code compiled and downloaded to Quisar 320 does not produce the same result as in PC. What can I do to make my code run and produce the correct result in Quisar 320? Someone knows a CRC routine specific to this model of machine? Thanks, Mauricio Harley
When you say, "addequate porting" are you sure? Remember that the PC has a different word size and different byte ordering. The fact that you have 2 working PC versions, but the embedded version fails, suggests that you have an unsafe dependency on the PC architecture. Check the thread, "onversion (sic) 8/16 bit types problem" http://www.keil.com/forum/msgpage.asp?MsgID=1109 Including the link to Mark Odell's site, which gives some platform-independence tips. The use of unions to access individual bytes of 16- or 32-bit words is particularly non-portable; eg, see Keil Knowledgebase article http://www.keil.com/support/docs/1279.htm (I'll collect my comission later, Mark!)
(I'll collect my comission later, Mark!) Okay, and thanks again. - Mark
Joe Campbell's 'C Programmers Guide to Serial Communications', ISBN 0-672-30286-1 has an excellent treatment of CRC. Hint. I believe that there is a 10 byte sequence that is used as a benchmark to see if a CRC is implemented properly. It is either 0-9 (decimal) or 1-10 (decimal). In any case, if you find a 'known good' crc program and you know what type it is, you can (should?) create your own data points.