cancel
Showing results for 
Search instead for 
Did you mean: 

Apparent error on the HAL SPI library when using DMA.

EngScn
Associate

Even after setting up a DMA stream to a SPI_RX DMA request, the HAL_SPI_Receive_DMA() function return error code 1 when called. I've solved this problem by also setting up a DMA stream to the SPI_TX request, even though I won't use it. 

Problem occurred when using SPI1 on Full-Duplex Master mode in the STM32F412 uC, STM32CubeIDE Version: 1.16.1

1 ACCEPTED SOLUTION

Accepted Solutions
Imen.D
ST Employee

Hello @EngScn ,

In Full-Duplex mode, both the TX and RX DMA streams need to be configured. 

Ensure that the SPI is disabled before calling the HAL_SPI_Receive_DMA () function to avoid overrun errors.

 
When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

View solution in original post

3 REPLIES 3
Andrew Neil
Evangelist III

@EngScn wrote:

Problem occurred when using SPI1 on Full-Duplex Master mode 


Surely, in a Full-Duplex master, you would have to have a TX running - so the behaviour is as expected?

 


@EngScn wrote:

function return error code 1


What does that code indicate?



Surely, in a Full-Duplex master, you would have to have a TX running - so the behaviour is as expected?


I would like to have only my RX using DMA. My TX would be transmitting data in polling mode. I believe this should justify using a DMA stream only to the RX channel?



What does that code indicate?


HAL_SPI_Receive_DMA() returns a HAL_StatusTypeDef, for code 1 that would be HAL_ERROR.

Imen.D
ST Employee

Hello @EngScn ,

In Full-Duplex mode, both the TX and RX DMA streams need to be configured. 

Ensure that the SPI is disabled before calling the HAL_SPI_Receive_DMA () function to avoid overrun errors.

 
When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen