26.02.2015 Views

User Manual - CNC4PC

User Manual - CNC4PC

User Manual - CNC4PC

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CRC Generation Function<br />

unsigned short CRC16(puchMsg, usDataLen)<br />

unsigned char *puchMsg ;<br />

unsigned short usDataLen ;<br />

{<br />

unsigned char uchCRCHi = 0xFF ;<br />

unsigned char uchCRCLo = 0xFF ;<br />

unsigned uIndex ;<br />

/* message to calculate CRC upon*/<br />

/* quantity of bytes in message*/<br />

/* high byte of CRC initialized*/<br />

/* low byte of CRC initialized*/<br />

/* will index into CRC lookup table*/<br />

while (usDataLen--)<br />

{<br />

uIndex = uchCRCHi ^ *puchMsgg++ ;<br />

uchCRCHi = uchCRCLo ^ auchCRCHi[uIndex} ;<br />

uchCRCLo = auchCRCLo[uIndex] ;<br />

}<br />

return (uchCRCHi

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!