AnsweredAssumed Answered

CRC-32 on F4/F7

Question asked by wired on Jun 27, 2016
Latest reply on Apr 24, 2018 by Matthew Vernon
Just thought I'd save people some time if they are trying to get the CRC engine on the F4/F7 to produce the same results as most online calculators.

If you are using CubeMX to configure your CRC, you need to specify the Input Inversion Mode as BYTE and the Output Inversion Mode as ENABLE.  Note that when ST uses the term inversion, what they really mean is bit reversal, or reflection.  Not sure why they think inverting is the same as bit reversal.

It would be nice if ST would make these the defaults, since the other defaults are for the 32-bit CRC.  If you use their defaults, you won't get a CRC that matches anything I could find with any online calculator.

Once you have the crc from HAL_CRC_Calculate(), you need to invert it (yes, I do mean invert, e.g. change ones to zeros and vice versa).  Since it is a uint32_t, you can just use crc=~crc.  This will give you the result as calculated by the following online calculators:

When you use the 2nd link, there are options you can specify, but if you just click the CRC-32 button, the default options are the ones that give you the same result as the first link.  Make sure you read how to enter hexadecimal values if that is what you want to do.

Hope this saves others some time.