Skip to main content
Associate II
August 5, 2024
Solved

HAL_SPI_Transmit_DMA() succeeds once; subsequent calls return HAL_BUSY

  • August 5, 2024
  • 2 replies
  • 954 views

I can fix the problem by enabling interrupts for the DMA channel. But WHY should this be necessary?

I'd prefer to do this with no interrupts. I allow ample time between calls so data transfers have plenty of time to complete.

(G4 chip, MX set up as SPI3 transmit only master with DMA on DMA2 channel1)

Thanks!

Best answer by Dave.Electron

Thanks TDK for your response which serves as confirmation that I'm using DMA correctly. I questioned because I thought that the idea of DMA was to eliminate interrupts entirely. With your response, I now understand that DMA eliminates interrupts during the transfer, but not at the end of the transfer. 

2 replies

TDK
Super User
August 5, 2024

When the transfer starts, the software state machine is set to BUSY. When it completes, the complete callback sets it back to READY. If you disable interrupts, you miss out on that second part.

You can do it without interrupts, or without HAL, but if you use HAL you have to play by its rules.

It is fine to manually set the software state machine to READY, as long as there are no secondary operations needing done, which there shouldn't be for SPI.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Dave.ElectronAuthorBest answer
Associate II
August 15, 2024

Thanks TDK for your response which serves as confirmation that I'm using DMA correctly. I questioned because I thought that the idea of DMA was to eliminate interrupts entirely. With your response, I now understand that DMA eliminates interrupts during the transfer, but not at the end of the transfer.