Post Go back to editing

CRC read calculation

Category: Datasheet/Specs
Product Number: ad7383x, ad7383

Dear all,

I've been working on figuring out the CRC read calculation for the AD7383-4 ADC. Based on the ADC datasheet, I wrote a MATLAB script for the 32-bit CRC calculation, and it correctly matches the remainder shown in the example (see the attached snapshot).

Since I'm using four 4-channel ADCs, I extended the same logic to handle 64-bit data + 8-bit CRC = 72-bit total. However, when I test this on hardware, the ADC result does not match expectations. Adding the CRC to the 64-bit data should result in a final remainder of zero, but unfortunately, that's not happening.

I'm attaching an ILA scope snapshot that shows all four channels, including the CRC read result. (Note: the output matches the input as I’m applying a 4 mV sine wave.)

I've spent a significant amount of time on this, but things still aren't lining up. I would greatly appreciate any help, suggestions, or leads you might have.

Thank you in advance.


Hardware result:




MATLAB CALCULATION FOR 32bit example of datasheet:






CRC RESULT CALCULATION HW RESULT:



MATLAB EXTENDED CODE:

% Define the polynomial (x^8 + x^2 + x + 1) as 9-bit binary
poly = uint16(bin2dec('100000111')); % 0x107

% Original ADC channel data (A, B, C, D)
data = [hex2dec('3904'), hex2dec('3902'), hex2dec('3900'), hex2dec('38f5')];
disp('Original Data:'), disp(dec2bin(data, 16));

% Step 1: Invert ONLY the 8 MSBs of Channel A (data(1))
msb = bitshift(data(1), -8);
inverted_msb = bitxor(msb, 255);
data(1) = bitor(bitshift(uint16(inverted_msb), 8), bitand(data(1), 255));

disp('Data after MSB inversion (only A inverted):'), disp(dec2bin(data, 16));

% Step 2: Concatenate 4 data words (64-bit total)
data_stream = uint64(0);
for i = 1:length(data)
data_stream = bitor(bitshift(data_stream, 16), uint64(data(i)));
end
disp('Concatenated Data Stream (64-bit):'), disp(dec2bin(data_stream, 64));

% Step 3: Append 8 zeros to the LSBs (72-bit)
padded_data_stream = [dec2bin(data_stream, 64), '00000000'];
disp('Data Stream after Appending 8 Zeros:'), disp(padded_data_stream);

% Step 4: Perform XOR-based CRC division
data_bits = padded_data_stream - '0';
poly_bits = dec2bin(poly, 9) - '0';

for i = 1:(length(data_bits) - length(poly_bits))
if data_bits(i) == 1
data_bits(i:i+length(poly_bits)-1) = xor(data_bits(i:i+length(poly_bits)-1), poly_bits);
end
end

% Step 5: Extract the last 8 bits as CRC
crc_remainder_bits = data_bits(end-7:end);
crc_remainder = bin2dec(num2str(crc_remainder_bits));

fprintf('CRC Remainder (Final CRC): 0x%02X\n', crc_remainder);
disp('Final CRC Binary:'), disp(crc_remainder_bits);