SBAA106A June   2020  – August 2021 ADS112C04 , ADS112U04 , ADS114S06 , ADS114S08 , ADS122C04 , ADS122U04 , ADS1235 , ADS1235-Q1 , ADS124S06 , ADS124S08 , ADS1259 , ADS1259-Q1 , ADS125H01 , ADS125H02 , ADS1260 , ADS1260-Q1 , ADS1261 , ADS1262 , ADS1263 , ADS127L01 , ADS131A02 , ADS131A04 , ADS131M04 , ADS131M06 , ADS131M08

 

  1.   Trademarks
  2. 1Introduction
  3. 2Simple Checksum
    1. 2.1 Checksum Code Example
  4. 3CRC
    1. 3.1 CRC Generic Computations
      1. 3.1.1 Using XOR Bitwise Computation
      2. 3.1.2 Using Lookup Tables
        1. 3.1.2.1 Table Initialization
        2. 3.1.2.2 CRC Computation
      3. 3.1.3 CRC Computation Differences Between the ADS122U04 and ADS122C04
        1. 3.1.3.1 Byte Reflection Example
        2. 3.1.3.2 Reassembling Data Using Byte Reflection for CRC Computation
  5. 4Hamming Code
    1. 4.1 Hamming Code Computation
      1. 4.1.1 Hamming Code Computation Example
        1. 4.1.1.1 Counting Bits for Parity and Checksum Computations
          1. 4.1.1.1.1 Example of Counting Set Bits in the Data
          2. 4.1.1.1.2 Example of Counting Set Bits Using a Lookup Table
      2. 4.1.2 Validation of Transmitted Data
        1. 4.1.2.1 Hamming Validation
        2. 4.1.2.2 Checksum Validation
        3. 4.1.2.3 Error Correction
  6. 5Summary
  7. 6References
  8. 7Revision History

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.