cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_SPI_ERROR_DMA

Rtomy.1
Associate II

Hi, I am using stm32f769Ni evk for a project. Here I am interfacing stm32 with a wifi module using spi dma . The communication fails during reception with HAL_SPI_ERROR_DMA after  /* Enable the Tx DMA Stream/Channel */

 if (HAL_OK != HAL_DMA_Start_IT(hspi->hdmatx, (uint32_t)hspi->pTxBuffPtr, (uint32_t)&hspi->Instance->DR,

                 hspi->TxXferCount))

 {

  /* Update SPI error code */

  SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_DMA);

  errorcode = HAL_ERROR;

  hspi->State = HAL_SPI_STATE_READY;

  goto error;

 }

The error is inconsistent and even on successful read the rxbuffer contains on 0x00 or 0xFF. Kindly help me with this

6 REPLIES 6
Bouraoui Chemli
ST Employee

 Hi

Can you please refer to STM32CubeF7 package and check this example configuration (SPI, DMA). Available via this path: STM32Cube_FW_F7_V1.16.1\Projects\STM32F722ZE-Nucleo\Examples\SPI\SPI_FullDuplex_ComDMA

Bouraoui

TDK
Guru

Step through HAL_DMA_Start_IT to see where it's failing. Not much going on in there. Either the stream is locked because the previous call isn't finished, or your size parameter is invalid.

https://github.com/STMicroelectronics/STM32CubeF7/blob/f8cefdf02e8ad7fd06bd38a2dd85a55ecdbe92a9/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_dma.c#L453

If you feel a post has answered your question, please click "Accept as Solution".

Hi Bouraoui,

Yes, I have referred this example. The issue is very random and it rarely happen when I put breakpoints. It happens after __HAL_DMA_ENABLE(hdma); call

Rtomy.1
Associate II

The issue is very random and it rarely happen when I put breakpoints. It happens after __HAL_DMA_ENABLE(hdma); call

AFinn.1
Associate II

Faced with similar situations on F767, F427. I will describe the situation with F427: The master controller periodically exchanges with the chip via SPI. The exchange is initiated each time by the HAL_SPI_TransmitReceive_DMA() function, after processing the HAL_SPI_TxRxCpltCallback() of the previous exchange. When a breakpoint is set before HAL_SPI_TransmitReceive_DMA(), receiving and transmitting returns HAL_OK, but if you run the same code without a breakpoint, HAL_SPI_TransmitReceive_DMA() returns HAL_ERROR and data exchange becomes impossible. When delving into the code, it turned out that when HAL_DMA_Start_IT() is executed, the HAL_SPI_ERROR_DMA bit is set in hspi->ErrorCode.

I will also check if the exchange is less frequent if this error occurs

JLiao
Associate II

Hi,

I got the same problem on the STM32L432KC.

Some time, the  HAL_DMA_Start_IT return the HAL_ERROR, and random happened at power up.

Now, I try to add the HAL_SPI_DeInit and HAL_SPI_Abort before the SPI Init.

Testing...