AnsweredAssumed Answered

AD7768 CHECK CRC

Question asked by andoon on Jan 28, 2018
Latest reply on Feb 2, 2018 by NiallM

hi,there!

I follow the datasheet to calculate  the CRC of channel,but I can not get the value same as the ADC's.

here is the four samples:

B507BD
94F6F2
D39BC9
395ED1

the CRC from the ADC is C8.

I use the tools from http://www.analog.com/media/en/engineering-tools/design-tools/AD7779-CRC-Calculator.zip ,the result is right.

But please help me with the MATLAB to get the right result.

here is the code:

 

p=[1 0 0 0 0 0 1 1 1]';
a=reshape(de2bi(data16(1,1:4),24,'left-msb')',96,1);
a=[a' 1 1 1 1 1 1 1 1]';
[m n]=size(a);

kkk = 9;
b = a(kkk-8:kkk,1);
while ((m-kkk)>0 )
if( b(1,1) == 1)
b = bitxor(b,p);
end

while ( (b(1,1) == 0)&&(kkk < m) )
kkk = kkk + 1;
b =[b(2:end,1)' a(kkk,1)]';
end
end

if( b(1,1) == 1)
crcchk = bitxor(b,p);
else
crcchk = b;
end
crcchk = crcchk(2:9,1)

 

Thanks for your help.

Outcomes