cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G4 CRC8 with user polynomial doesn't match other method

YWang.31
Associate II

Hello, there,

I need CRC8 in my design. Thinking with the Polynomial programmability in Stm32G4 . It should be straight forward.

When I tried to test with the example "CRC_UserDefinedPolynomial" coming with stm32cube_fw_g4_v130 in "Examples_LL" folder, the result (0xA6) matches the "expected value" set in the code.

However, when the same group of the data is tested with other CRC calculator for Poly 0x9B, eg. https://crccalc.com/, the result is 0x88 instead of 0xA6.

Then I tried another example (different data set 0x1, 0x2, 0x3, 0x4) with HAL, the result doesn't match either.

0693W000003QyciQAC.jpg0693W000003QycTQAS.jpg

The CRC hardware is a blackbox so I couldn't figure it out why. Is there anyone having running into similar issue and knowing the cause of the mismatch?

I would like to appreciate any inputs.

Thanks.

11 REPLIES 11

Don't think this requires internal info, CRC's by their nature are very sensitive to bit and byte ordering.

ST has some very awkward shift direction and endian ordering issues.

These issues are compounded by the use of online calculators rather than foundational understanding of LFSR/CRC mechanics and math.

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

CRC is not rocket science at least in application. Done many with FPGA and software by shifter and LUT. I can simply implement it in code without spending time on it. Just the curiosity was not satisfied.

As you mentioned, it's very sensitive to the direction and data arrangement. If it's not disclosed, it's hard to figure out.

After getting it right, think I figured out how the ST CRC works immediately and believe somehow the insiders may have some miscommunication.