Skip to content
Javier Fernández edited this page Mar 5, 2020 · 2 revisions

CRC implementation

The description of the CRC used by Motion Control Bus protocol is:

Parameter Value
Width 16 bits
Polynomial 0x1021
Seed 0x0000

It is commonly known as CRC-CCITT "XMODEM". During CRC development it is recommended to use this online tool for validation:

https://www.lammertbies.nl/comm/info/crc-calculation

Example

Header Config data CRC
0x0204 0x86A0000100000000 0xA2C7

The library supports three strategies for CRC implementation:

  1. Pure software
  2. By software with hardware support
  3. Pure hardware

This library support all of them.

Pure software

It is the default method (Mcb_IntfComputeCrc) available on the mcb_usr.c file. This strategy doesn't require any additional implementation from the user.

Software with hardware support

If the platform has hardware accelerators for the CRC calculation, the function Mcb_IntfComputeCrc may be overwritten by the user because it is declared as weak.

Pure hardware

If the device is able to compute automatically the CRC at the end of the SPI transfer, the function Mcb_IntfComputeCrc may be disabled by setting the parameter bCalcCrc as false during the initialization of the MCB instance.