cancel
Showing results for 
Search instead for 
Did you mean: 

SPI Slave DMA with CRC

UlfS
Associate

Dear ST,

I facing a problem or bug in the calculation routine of your stm32f7xx_hal_spi.c

Explicit in line 3117 of the function call:  SPI_DMAReceiveCplt()

I using DMA SPI only the MOSI channel as RX_Only. This works as expected, when I dont activate CRC calculation. If crc is enabled (in 8Bit Datasize) the rountine raised the condition: RXNE timeout als HAL Error. 

1. Why you check during that time the RXNE flag anymore, during the function call is that flag usualy already not set anymore, when the DMA ITQ was raise? To  see here:

    if (hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE)
    {
      /* Wait until RXNE flag */
      if (SPI_WaitFlagStateUntilTimeout(hspi, SPI_FLAG_RXNE, SET, SPI_DEFAULT_TIMEOUT, tickstart) != HAL_OK)
      {
        /* Error on the CRC reception */
        SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_CRC);
      }
2. I don't see chance to use SPI as 2Line RX_only with enabled crc calculation, isn't it? I read something I have to use instead the TransmitReceive function in that purpose because, this bug was never fixed, is that correct?
 
3. Why the SPI datasize depends in the crc size calculation? I use the SPI datssize of 8Bit for 36KBytes payload and want in the end a crc calcualtion of a 16BIT crc, but when I take a look in the HAL code, they avoid these  configuraion setting, means: When I want 16Bit CRC in theend, I have to change the Datasize of from the SPI to 16Bit datasize, but why? My frame is not 16Bit organized.  
 
Best
Ulf
1 REPLY 1
LLECH.1
ST Employee

Dear UlfS,

1. We check RXWNE flag with SPI_WaitFlagStateUntilTimeout() to verify that there is no more data in RX FIFO, otherwise it woud mean that the transfer is not completed.

 

2. Sorry I don't understand your point, could you reformulate your question please ?

 

3. The CRC length doesn't depend on data size unless you set Init.CRCLength to SPI_CRC_LENGTH_DATASIZE. If you want the 16-bit size CRC you can initialize Init.CRCLength to SPI_CRC_LENGTH_16BIT

 

Best Regards,

Lucas