SBAA106A June   2020  – August 2021

2. 1Introduction
3. 2Simple Checksum
4. 3CRC
1. 3.1 CRC Generic Computations
1. 3.1.1 Using XOR Bitwise Computation
2. 3.1.2 Using Lookup Tables
3. 3.1.3 CRC Computation Differences Between the ADS122U04 and ADS122C04
5. 4Hamming Code
1. 4.1 Hamming Code Computation
1. 4.1.1 Hamming Code Computation Example
2. 4.1.2 Validation of Transmitted Data
6. 5Summary
7. 6References
8. 7Revision History

## 4.1 Hamming Code Computation

The Hamming bits are considered interleaved with the data, but the actual transmission is not interleaved. However the data are consistently transmitted the same way. As was previously discussed, simple bit masks can be used to evaluate and compute the Hamming bits instead of using a method of shifting and XORing the data. There are two possible methods for counting the bits. One method is to loop through the masked data and count each time a "1" occurs. This method is rather time consuming similar to the CRC bitwise operation. The second method uses a table to evaluate the data directly which is a much faster method of determining the number of "1"s in the masked data.

After computing the number of "1"s for each of the Hamming bits, the computed value is XORed with the corresponding Hamming bits from the transmitted data. The correct response is zero. If the value is nonzero, then the result can be evaluated to determine which bit is in error. What is special about this process is a single bit error can be corrected. The bit in error could either be a Hamming parity bit error, or an error with a bit in the data. Single bit error correction is possible as each data bit is covered by more than one Hamming parity bit. However, there are some possible combinations that can result in multiple bit error, or combinations of the Hamming bits relative to the data where the data may appear to be correct but is not. The use of the checksum bits along with the Hamming bits represent a more comprehensive solution than analysis of the Hamming bits alone.

To determine if there is a transmission error, the incoming data is computed to determine the expected Hamming bits. The computed Hamming bits and checksum are compared using an XOR to the Hamming byte received. If an error is found with the computation returning a value greater than zero, a correction table is used to make the bit correction once an error is found. The correction table shown in Section 4.1.2.3 would be used with the ADS131A0x devices. The table applies to the complete SPI word transmitted for both the data and Hamming bits. The least significant 3 bits, which are the checksum bits and the constant zero, are excluded. Following the bit-correction, a checksum of the data is then computed by counting the number of "1" bits contained in the restored data. From the computed checksum, the least significant two bits are compared to the checksum bits transmitted in the Hamming byte by XOR. If the checksum fails, then there are multiple bit errors in the data.