| Purpose: | Calculate the next CRC WORD given the prior CRC WORD and the next BYTE in the sequence. | ||||
| Assumes: | The CRC generator polynomial is x15 + x13 + x0 (which is the value 0xA001 or 1010000000000001.) | ||||
| Passed: | R25:R24 | WORD | wPriorCRC | the previous 16-bit CRC value (i.e., its accrued value so far) | |
| R22 | BYTE | bNewByte | the next data BYTE to include in the CRC | ||
| Returns: | R25:R24 | WORD | wCRC | the new 16-bit CRC value, with bNewByte included | |
| Alters: | No Registers (i.e., only the R25:R24 value returned and the FLAGS) | ||||
| Example: |
|
| Test it: |
|
| Notes: | When a CRC WORD is initialized to 0xFFFF, changes in blocks that begin with runs of zeros can be detected. When the initial CRC is 0x0000, they cannot be detected. |
| Refer to the CRC System Function for more general information about CRCs. More more information is available online. | |
| The CRC System Function calculates a 16-bit CRC over a block of SRAM | |
| Dropin: (setup code) |
; Setup for the CRC() call: ; Passed: R25:R24 WORD wPriorCRC the existing CRC value accrued so far ; R22 BYTE bNewByte the next data BYTE to combine into the CRC ; Returns: R25:R24 WORD wCRC the new 16-bit CRC value, including the new byte ; Alters: R24, R25 and the FLAGS (R25:R24 has the return value) |
| Also see: | The CRC System Function. |