cancel
Showing results for 
Search instead for 
Did you mean: 

Incorrect CRC value from software and harware SPI CRC

WCarey
Associate III

Hi, 

In my application, I'm using SPI (SPI1, a full feature set instance) with CRC enabled, on STM32H563ZI, with the configuration as:

WCarey_0-1713170183201.png

I have a CRC implemented based on CCIT standard, which I call 'software CRC'

I see different CRC values for the same bytes of input from the micro and software CRC. 

WCarey_2-1713170893568.png

Fig1. Software CRC which is 0x8B2C (the last 2 bytes shown in Logic Analyzer, with msb first configuration)

WCarey_3-1713170932398.png

Fig2: CRC from ST which is 0x5D0C for the same input.

My software CRC calculation is not wrong and is verified using this calculator (https://crccalc.com/) which yields 0x8B2C.

WCarey_1-1713170240836.png

 

Kindly help in understanding why the 'hardware' CRC is different from 'software'.

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
WCarey
Associate III

The CRC Polynomial for my software CRC calculation is 0x1021. However, in SPI CRC calculation I had to use 0x11021 to get the same result as software.

View solution in original post

7 REPLIES 7

It's hard to analyze when the message is long. Try one byte first.

How exactly is SPI set up (post perhaps read out content of registers) and how exactly do you feed data to it?

JW

Apologies for the late reply. I could not get the registers content as I'm having trouble viewing the 'Registers Window' in Keil. 

Here's my SPI configuration.

WCarey_0-1713427153769.png

 

I use UART to send/receive data to/from my master from a terminal

The master then talks to slave via SPI

WCarey
Associate III

I have another question. I use HAL_SPi_TransmitReceive_DMA APIs for SPI Tx & Rx i.e during Tx, *pRxData is dummy data and vice versa for Rx. 

So, I get a CRC error  during Tx as my TransmitReceive API checks for Rx CRC of dummy Rx data. How to handle this?

Sorry, I don't know, I don't have experience with CRC in SPI.

JW

WCarey
Associate III

The CRC Polynomial for my software CRC calculation is 0x1021. However, in SPI CRC calculation I had to use 0x11021 to get the same result as software.

This is surprising; although the description in RM may hint at it (that description is rather messy).

Thanks for coming back with the solution.

JW