CRC7 Polynomial?
Javalin
Posts: 892
Hiya all,
I have a question, and I have to admit that I may not fully understand the answer. Sadly my maths are not wonderfull... :-(
I've been trying to get the CRC7 & CRC16 working on my SD card object, and after lots of reading have re-written a C example in SPIN - which works:
However why is the poly $9 not $89 (%1000_1001)? as it is generated by x^7 + x^3 + 1?
Thanks,
James
I have a question, and I have to admit that I may not fully understand the answer. Sadly my maths are not wonderfull... :-(
I've been trying to get the CRC7 & CRC16 working on my SD card object, and after lots of reading have re-written a C example in SPIN - which works:
PUB crc7(buffer,count) | crc, c crc := 0 repeat count c := byte[buffer++] repeat 8 crc <<= 1 if (c ^ crc) & $80 crc ^= $9 c <<= 1 result := crc & $7F
However why is the poly $9 not $89 (%1000_1001)? as it is generated by x^7 + x^3 + 1?
Thanks,
James
Comments
-Phil
:-)
J
-Phil
to
I get a different result. I don't get it - I thought the x^7 + x^3 + 1 = %1000_1001, but the $9 is just %1001 so why? Unless its just how this implemention works?
James
PS - how do you do bold, itallics and colour on this forum software now????
For formatting assistance, go to the forum FAQ and do a search on bbcode.
-Phil
Thanks Phil.
James
Use [ I ] text to be italics [ / I ] For italics, use [ U ] text to be underline [ / U ] for underline and use [ B ] text to be bold [ / B ] for bold.
PS: Remove all spaces between the [ and ]!
Or you can use the B / I / U buttons (under the font selection box in the editor)
Now for the color...
[ COLOR = "Red" ][ / COLOR ] will produce Red,
[ COLOR = "Green" ][ / COLOR ] will produce Green, etc.
PS: Remove all spaces between the [ and ]!
Or, in the editor, next to the sizes drop down list, is a big A with a color line under it
select that drop down and pick your color!
James
You can also put your BBcode examples between [noparse][noparse] and [/noparse][/noparse] tags so you don't have to insert the extra spaces.
-Phil
I believe the "crc ^= $9" is correct. You should verify it with data that includes a known good CRC7 code.
Dave
This is odd, I guess Dave is right. If I use $89 or $9 it still works. I've only got one test case at the moment (the CMD0 init string for SD cards) - so might behave differently with more testing
Was sure I tested both - perhaps that was a previous attempt....
Cheers both.
James
Dave
You haven't anything for the crc16 CCITT one have you??? - thats the next task to get it working for the SD card data blocks...
Found this so far:
from http://www.drdobbs.com/199904926;jsessionid=5XQ05NE50QGWLQE1GHPCKH4ATMY32JVN
which i've translated as :
Doesn't work though - comes out at
thanks again,
James
$8408 is the bit-reversed value of $1021. It depends on whether the data is shifted out MSB first or LSB first.
Dave
Thanks!
James
An important property of the polynomial generator is the width, which is defined as the position of its highest bit set to 1. The high-order bit of the polynomial is omitted when representing the divisor itself because the high-order bit should always be equal to 1. This makes sense if you look at the CRC in binary long hand.
Here is a link to something I did awhile back for our RF modules...
http://forums.parallax.com/showthread.php?t=117333&highlight=polynomial+schwabe
Reference:
http://www.ross.net/crc/download/crc_v3.txt
On the result, just add the stop bit and you all set.
for example:
CMD17 (Argument=0) --> 01 010001 00000000000000000000000000000000 "0101010" 1