From: Roger Stafford on 18 Nov 2005 14:34 In article <4299367.1132302243123.JavaMail.jakarta(a)nitrogen.mathforum.org>, Aaron <aaronshchang(a)hotmail.com> wrote: > Hi Roger, > > I was actually using that "Painless" guide parallelly when writing this crc programme. I took to referring to the value hex 29B1 as the reference value to the string '123456789' just because a check using this string on a few online CRC-CCITT calculator delivered hex29B1 as the resulting value and not E5CC as delivered in the paper.. I will check again their differences especially with the difference between the results, 29B1 and E5CC as cited in the " http://www.joegeluso.com/software/articles/ccitt.htm" article. > Thanks for your help -------------------- Hi Aaron, I am sticking my neck out here because I don't have the 'bitshift', 'bitxor', 'bitget', 'unit16', or 'unit8' functions to try this out. However, it seems to me the following might work. I have followed the outline of your previous code. If it's right, it should give E5CC (if we are to believe the website I mentioned.) a001 = uint16(hex2dec('1021')) %CRC16-CCITT polynomial str = uint8([hex2dec('FF') hex2dec('FF') '123456789']); % <= Put 'FFFF' here crc = uint16(0); for i = 1:length(str) crc = bitxor(crc,bitshift(uint16(str(i)),8)); for j = 1:8 droppedbit=bitget(crc,16); crc = bitshift(crc,1); if droppedbit crc = bitxor(crc,a001); end end end .. (Remove "xyzzy" and ".invalid" to send me email.) Roger Stafford
First
|
Prev
|
Pages: 1 2 Prev: Plotting SNR vs BER using QPSK signal. Next: Hough transform circle detection optimization |