I have to implement a communication protocol which runs via I2C and is used for a board2board communication of two distributed microcontrollers. To ensure the data integrity, I want to add to the communication protocol a checksum and thought something like CRC-8 or CRC-16 should fit, but unfortunately I have no glue, which criteria I should use to determine the best algorithm and in the next step, the best setting (like the value of the polynomial in case of CRC).
My protocol is quite simple, only one 32-bit read and one 32-bit write command are defined:
I2C Master Read Command:
- Request (I2C WR): 2 bytes memory index + checksum
- Response (I2C RD): 4 bytes data + checksum
I2C Master Write Command:
- Request (I2C WR): 2 bytes memory index + 4 bytes data + checksum
I read on a forum post, that the CRC length depends on the data size which should be verified, so CRC-8 can sufficiently verify 28 % 8 (=32bit) and 216 % 8 (=8KiB) data for CRC-16. If that`s true, CRC-8 should be enough, but I don't know if this statement is correct...
Can someone please help me, how I can determine the best checksum algorithm for my protocol?