cancel
Showing results for 
Search instead for 
Did you mean: 

SPI CRC via DMA dosen't work

UlfS
Associate II

Dear ST,

 

I use STM32F777 and try to receive SPI Data as a slave via SPI DMA. That works only pretty fine, when I don't activate the CRC Checksum calculation. I receive after the DMA threshold the expected data, but when I set: 

.CRCCalculation = SPI_CRCCALCULATION_ENABLE, 
The received data traped in a Error Callback from the SPI, always.
 
All my init values of the SPI are vaild, look like here:
.SPI_CONFIG = {.Mode = SPI_MODE_SLAVE,
                                                             .Direction = SPI_DIRECTION_2LINES_RXONLY,
                                                             .DataSize = SPI_DATASIZE_8BIT,
                                                             .CLKPolarity = SPI_POLARITY_LOW, // => CPOL = 1
                                                             .CLKPhase = SPI_PHASE_2EDGE, //=> CPHA = 0
                                                             .NSS =  SPI_NSS_SOFT, //SPI_NSS_HARD_INPUT,
                                                             .BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2,
                                                             .FirstBit = SPI_FIRSTBIT_MSB,
                                                             .TIMode = SPI_TIMODE_DISABLE,
                                                             .CRCCalculation = SPI_CRCCALCULATION_ENABLE, // ToDo activate CRC
                                                             .CRCPolynomial = CRC16_CCIT_ZERO, // ToDo activate CRC
                                                             .CRCLength =   SPI_CRC_LENGTH_16BIT,//, //ToDo activate CRC
                                                             .NSSPMode = SPI_NSS_PULSE_DISABLE},

Poly is 0x1021

Inti value is 0x0000

 

If I use the CRC HW Unit via SW, that works as well. But I still have to use the combination of DMA and CRC, because that part is on our application, very time critical. I still can not use the CPU instead.

10 REPLIES 10

The CRC is NOT going to be in the DR, the DR is 8-bit in your configuration.

If you're sending the data with the CRC, you send the data payload, and then once that is gone you read the TX CRC register, and send that.

The way you're describing it you sound like you want to receive four bytes and respond with the CRC.

In the receive sense, I'd expect you'd have to receive SIX bytes, and then the CRC will ZERO out

If you sent the 0xA5 0xA6 0x8C 0x00 0x07 0xFA pattern, the CRC correct check being the bit that checks RX CRC==0

I agree that the CRC16 for 4-byte MSB First should be 0x07,0xFA

ST should probably provide the validated test cases, I'm not invested to build a complete example

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