02-23-2016 01:31 AM - edited 02-23-2016 01:33 AM
I'm using matlab script in labview to calcualte the crc16 valure of a Integer array,but something seems wrong .
The code test ok in matlab:
the labview program test wrong:
Is there anything need to modify? thanks!
the m-file is:
crc_ccitt_matlab.m
function crc_val = crc_ccitt_matlab (message)
crc = uint16(0);
for i = 1:length(message)
crc = bitxor(crc,bitshift(message(i),8));
for j = 1:8
if (bitand(crc, hex2dec('8000')) > 0)
crc = bitxor(bitshift(crc, 1), hex2dec('1021'));
else
crc = bitshift(crc, 1);
end
end
end
crc_val = crc;
end
02-23-2016 01:48 AM
02-23-2016 01:54 AM
yes,i have installed matlab r2010b , and in some other programs the matlab scripts can work.