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
The discussion of Hamming Code (HC) is limited to how the code is used for data integrity checks for ADCs. HC is used to correct one bit of error for a transmitted data block. Hamming codes work well for verifying small data packets. HC cannot detect all multiple bit errors, and multiple bit errors cannot be corrected. The implementation of the Hamming byte used for the ADS131A0x devices includes the HC as well as checksum bits for determining multiple bit error.
For the ADS131A0x devices the HC is made up of five bits (H0-H4) and the bits are interleaved with the data as shown in Figure 4-1. Parity is used to determine the value of each bit in the HC relative to specific bits mapped to the data. Conceptually, the HC bits are interleaved within the data bits. The result is multiple Hamming bits are covering each data bit. This is an improvement upon early data communication when only a single parity was used for data validation. The HC now uses multiple bits to find and correct a single-bit error. Simple parity computation involves counting the number of 1's in a data packet where the parity bit will be either one or zero depending on whether the parity is considered to be odd or even. Odd parity correlates to an odd count, and even parity to an even count. The Hamming bit is set to make the count even parity for the ADS131A0x devices.
The data word for the ADS131A0x family of devices can be either 16-bits or 24-bits. The Hamming byte consists of five Hamming bits with H4 as the most significant bit. Following the Hamming bits are two checksum bits. The least significant bit of the Hamming byte is a constant equal to zero. The total transfer of the data word and the Hamming byte can be either 24-bits or 32-bits. For this discussion we will consider the 32-bit word length consisting of the 24-bits of data along with the Hamming byte.
The five Hamming bits become a part of the data word and are compared to the parity representation of each bit so that the combination of the Hamming parity covers the data bits at least twice so that if a bit is incorrect it can be reconstructed from the remaining Hamming parity bits. For checking if multiple bits have error, then the 2-bit checksum data is used to verify if the result shows a single bit error, or multiple bit error.
The table data in Figure 4-1 shows the parity bit coverage for each Hamming bit with the Hamming bits interleaved within the data. Each row of the table indicates which data bits are included in each Hamming bit. Note that the table is showing the bits with the least significant bit at the left-hand side of the table and the most significant at the right-hand side. The bits that are checked are indicated in the columns, and the rows are representing the Hamming parity bit. Information from the table can be used to determine a Hamming mask for each Hamming bit. The Hamming mask is used to validate the Hamming bit associated for the mask. The mask only includes the data bits used for a particular Hamming bit. When converting the table to the Hamming mask used in computation, the 32-bit values are read from left to right and the data would exclude the Hamming bits in the mask.
Transmission of the data to and from the ADS131A0x devices is most significant bit (msb) first through the least significant bit (lsb) of the data. The Hamming bits will follow in the byte after the data are transmitted. The Hamming is not interleaved within the output as shown in the Figure 4-1. Instead the Hamming is appended to the transmission of the device data as a separate byte. The Hamming bit values will still follow the same pattern and computation but the placing of the Hamming byte following the data is by design. Placing the Hamming byte as the least significant byte (LSB) transmitted allows the user to easily ignore the byte if desired or not transmitted at all if disabled. This allows the device data to appear the same independent of having the Hamming enabled. The Hamming byte also contains the checksum of the data as a 2-bit value (C1 and C0) representing the number of bits set to "1". The least-significant bit (F0) is a fixed constant with a value of "0". The appearance of the transmitted data and Hamming byte will follow the format shown in Figure 4-2.
When computing the Hamming bit parity, each Hamming bit will follow the pattern shown in Table 4-1 where each bit can be determined by masking out the bits not computed. Using this method greatly simplifies the computation for verifying the data transmission.
HAMMING BIT | MASK VALUE (32-bit) |
---|---|
H0 | 00DAB555h |
H1 | 00B66CCCh |
H2 | 0071E3C3h |
H3 | 000FE03Fh |
H4 | 00001FFFh |
The mask is applied to the data multiple times while counting the number of "1" bits and comparing to the appropriate Hamming parity bit. The masking of the bits is allowed as no Hamming bit includes any other Hamming bit in the parity computation. Also, every data bit is checked by more than one Hamming bit. A Hamming bit error could occur, but will be indicated if the data bits are verified within the other Hamming bit checks. If a data bit is in error, there will be more than one Hamming bit indicating the error in the parity check. When the parity computation is compared to the Hamming bits, the difference will point directly to the data bit in error.
To demonstrate the computation, a 24-bit data example is shown using the value of AC9538h. The results are shown in Table 4-2 for each of the Hamming bits. The process of computation is as follows:
HAMMING BIT | DATA (HEX) | MASK (HEX) | RESULT (HEX) | RESULT (BINARY) | BIT COUNT | HAMMING VALUE |
---|---|---|---|---|---|---|
H0 | AC 95 38 | DA B5 55 | 88 95 10 | 1000 1000 1001 0101 0001 0000 | 7 (odd) | 1 |
H1 | AC 95 38 | B6 6C CC | A4 04 08 | 1010 0100 0000 0100 0000 1000 | 5 (odd) | 1 |
H2 | AC 95 38 | 71 E3 C3 | 20 81 00 | 0010 0000 1000 0001 0000 0000 | 3 (odd) | 1 |
H3 | AC 95 38 | 0F E0 3F | 0C80 38 | 0000 1100 1000 0000 0011 1000 | 6 (even) | 0 |
H4 | AC 95 38 | 00 1F FF | 00 15 38 | 0000 0000 0001 0101 0011 1000 | 6 (even) | 0 |
The computation of the checksum bits is based on the number of "1" values in the binary representation of the data. Continuing to use the hex data of AC 95 38h, the hex value is converted to binary and the number of "1"s counted that represent the value. The binary conversion results in "1010 1100 1001 0101 0011 1000b" and the number of "1"s represented is decimal 11. The value of 11 in binary is "1011b." The checksum is computed by adding all 24 data bits with the modulo of 4. To simplify the computation and avoiding the modulo 4 math only the two least significant bits are used as the checksum bits. For this example the checksum is simply "11b".
The entire Hamming/checksum byte would appear in the format shown in Figure 4-2, which is H4, H3, H2, H1, H0, C1, C0, 0. For the example using 0xAC9538, the bit binary representation of the Hamming/checksum byte becomes "0011 1110b".