AnsweredAssumed Answered

Trouble using STM32F4's CRC on 8 bit array

Question asked by zhao.frank on Jan 12, 2014
Latest reply on Jan 12, 2014 by Clive One
I am using a STM32F4's internal CRC peripheral

My test sample data works against the code available at http://www.opensource.apple.com/source/xnu/xnu-1456.1.26/bsd/libkern/crc32.c

Sample data is { 0xA1, 0x11, 0xC0, 0x00, 0x83, 0x81, 0x7E, 0x7E, 0x08, 0x00, 0x3C, 0x00, 0x00, 0x83, 0xA2, 0x07, 0xF1, 0xFF, 0xF9, 0xFF, 0x04, 0x00, 0x21, 0x03, 0x17, 0x1F, 0x29, 0xF9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00 } Length is 75

When I pass it into the function at http://www.opensource.apple.com/source/xnu/xnu-1456.1.26/bsd/libkern/crc32.c with an initial CRC of 0, it produces 0x0B5D0A7D, which is correct because it matches what my target black box device produces.

The STM32F4's CRC does not produce the same result at all, I have tried several techniques

First problem, the CRC initial value is 0xFFFFFFFF and I can't change it according to appnote 4187.

Second problem, the DR register is 32 bits, but my data length is 75.

For the first problem, I tried to set the DR to 0 by feeding it 0xFFFFFFFF first, it does make DR 0 but my CRC performed on my sample afterwards still does not match

For the second problem, I have tried several things:

I tried passing in 8 bit values. I tried both little and big endian.

I even tried use the hardware CRC for the first 18 uints and then passing the last 3 bytes into a the C code I mentioned above

None of these techniques worked.

How can I solve these two problems in a way that I can generate a CRC with my sample that matches my target?

Outcomes