cancel
Showing results for 
Search instead for 
Did you mean: 

Is there any resources that explains the work flow of the hardware CRC32 or how to make it works as standards CRC32?

HMoun
Associate

I have a module that uses the STM32F091RC MCU and trying to connect it with software using C# language.

At the first the connection has worked properly, then I've used the CRC32 to verify the sent data but it didn't work.

Ive read the "Application note AN4187" and implemented it, I've tried many combinations of CRC32 settings including input data / output data reversion and bit flipping the resulting CRC and nothing matched the results of CRC32 standards when I compared the results using online calculators.

Is there any resources that explains the work flow of the hardware CRC32 or how to make it works as standards CRC32?

6 REPLIES 6

Seem to recall posting examples where it was used to compute a more classical form.​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

https://community.st.com/s/question/0D50X00009XkbNMSAZ/crc-computation

https://community.st.com/s/question/0D50X0000BEZ3EqSQL/stm32f42xx-crc-stopresume

Basically got to do a bit-reversal on the 32-bit words going into the accumulator, manage the odd bytes left at the end, and bit-reverse & invert accumulated value at the end.

You'll get the same CRC for a file archived by PKZIP or WinRar

The main issue with the STM32 implementation is the endian vs shift behaviour of the 32-bit word are incongruous. A lot of people using the online calculators really lack any understanding of the mechanics.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

The 'F0 already has the reversal control settable in CRC_CR.

So, with the default POLY and INIT, you set REV_IN to 0b01 and REV_OUT to 1 when resetting CRC, feed the machine, and then invert the output, you should receive what most consider to be CCITT-32.

The main gotcha with the STM32 CRC is IMO that it works bytewise even if you feed it with words, but breaks down the word to bytes MSB first.

JW

Hi Clave

Thanks for your comment

I used the code you put in your comment in C# and reveresed the inputdata and output data from CRC_CR register with all possible settings but I had no matched result with the code.

what do you mean by "manage odd bytes left at the end"?

Do I have to reverse the data I need to check before I pass them to HAL_CRC_Calculate();?

what are the configurations should I set in the MCU?

Post examples of input data and expected CRC.

JW

>>what do you mean by "manage odd bytes left at the end"?

I mean that when you have an implementation that consumes 4-bytes at a time you have to manage the situations when you are left with 1-3 residual bytes at the end.

>>Do I have to reverse the data I need to check before I pass them to HAL_CRC_Calculate();? what are the configurations should I set in the MCU?

To do the same CRC32 as used by PKZIP, et al you need to set up the STM32 to do its standard/default 32-bit implementation (I'm sure there are examples), and feed it bit-reversed data

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..