SLAU358Q September 2011 – October 2019
The 16-bit (2-byte) checksum is calculated over all received or transmitted bytes, B1 to Bn, in the data frame except the checksum bytes themselves. The checksum is calculated by XORing words (two consecutive bytes) and bit-wise inverting (∼) the result, as shown in the following formulas.
CHECKSUM = INV [ (B1 + 256 × B2) XOR (B3 + 256 × B4) XOR...XOR ((Bn – 1) + 256 × Bn) ]
or
CKL = INV [ B1 XOR B3 XOR...XOR Bn–1 ]
CKH = INV [ B2 XOR B4 XOR...XOR Bn ]
An example of a frame for the Execute Self Test command with checksum would appear as:
0x3E 0x35 0x06 0x06 0x00 0x00 0x00 0x00 0x00 0x00 0xC7 0xCC