Skip to main content
Ftaht.1
Associate
October 1, 2021
Question

Calculated CRC value does not match incoming CRC value

  • October 1, 2021
  • 1 reply
  • 1642 views

Hello

I'm having trouble calculating crc. I am using STM32F401 with cube ide.

The correct crc occurs on crccalc.com. But I couldn't run CRC-8 with MCU. I have looked at the examples, but when I try it gives different results.

0693W00000FBAhRQAX.png 

Can you provide a working code example?

This topic has been closed for replies.

1 reply

Tesla DeLorean
Guru
October 1, 2021

Sorry, but in what context?

I don't recall the F4 provides a programmable CRC peripheral, is this under SPI? Please elaborate on the application.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Ftaht.1
Ftaht.1Author
Associate
October 1, 2021

I'm getting the data with I2C. For example, incoming data;

0x17 0X1D 0x00 0x0A

Data is: 171D00

CRC is : 0A

I must use CRC-8, http://smbus.org/faq/crc8Applet.htm

x8+x2+x+1

i don't know how to calculate this crc-8 with mcu :(

When I calculate via http://crccalc.com, input: 171D00, result is 0A (this is ok)

I couldn't get this result when I calculated it with mcu.

I tried the library here. But the result does not match

https://stm32f4-discovery.net/2015/07/hal-library-10-crc-for-stm32fxxx/

Thanks for help

Tesla DeLorean
Guru
October 1, 2021

>>I couldn't get this result when I calculated it with mcu.

Right because the MCU has a fixed 32-bit CRC / Polynomial implementation in hardware which is entirely unusable for your application

>>i don't know how to calculate this crc-8 with mcu

A regular software implementation would work

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