cancel
Showing results for 
Search instead for 
Did you mean: 

Does anyone know of an example showing SPI implemented with DMA on freeRTOS? I was not able to get this running. When I check the data variable in DMA2_Stream0_IRQHandler, it is always 0 when I expect it to be 1. I'm using the STM32F407G DISCO.

LMorr.3
Senior II

I have SPI set in Master Receive Mode Only and my code does work when not passing data to DMA.

5 REPLIES 5
Sarra.S
ST Employee

Hello @LMorr.3​,

Have you checked the CubeFW example of SPI data buffer transmission and reception with DMA?

It's not with freeRTOS though

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

LMorr.3
Senior II

Thanks, I'm looking at that sample code now. One issue is that I'm not clear on what libraries I should be using. HAL libraries are discouraged, which leave me with bare-metal. I wish someone would just post a simple explanation on how CMSISV1, CMSISV2, HAL, LL, and all the other 'libraries' work together and which ones are deprecated. Seems like a very messy approach grown over the years by folks who are way to deep to get a new-comer's eye view on getting setup. All official docs recommend HAL but then sample code now shows library usage I've not come across yet ( LL_ ) so I'll have to learn about that before I can proceed. Still not sure if I should now focus on coding with LL instead of bare metal, CMSIS or HAL.

LMorr.3
Senior II

To partly answer my own questions: HAL does not seem to support DMA for Master receive only mode. Its functions expect DMA to be setup for tx as well or exits with HAL_ERROR. Will look at using CMSIS to see if that helps.

Also, I think LL is no longer supported.

LMorr.3
Senior II

UPDATE:

I always see hdmarx status 'HAL_DMA_STATE_ABORT' in DMA2_Stream0_IRQHandler each time I call HAL_SPI_Receive_DMA(hspi,pData, Size)

Not sure what would cause that.

LMorr.3
Senior II

I am all set now, thanks!