cancel
Showing results for 
Search instead for 
Did you mean: 

Sending data to SPI via DMA

WKowo
Associate II

I'm using STM32F429 and trying to use HAL library to communicate to SPI slave via DMA channel.

I'd like to ask how is resolved problem with for example sending data to SPI via DMA? Is there any kind of synchronization between SPI and DMA to disallow overwritting SPI DATA register by DMA when SPI is sending previous SPI DATA register? In other words - how DMA knows how fast it should move data from source buffer to SPI DATA register to not overwrite its contents?

Is there any synchronization protocol which tells DMA to stop transmitting to SPI DATA register because SPI is currently busy with transmitting previous SPI DATA register?

1 ACCEPTED SOLUTION

Accepted Solutions

The DMA is triggered byte the SPI TXE flag, the DR holding register​ is separate from the internal shift register that puts the data on the wire.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

3 REPLIES 3
Gabriel Melo
Associate III

The DMAs on STM32 microcontrollers can generate two interruptions: HalfTransfer and TransferComplete.

You can use the latter to know when the data is sent and start sending new data.

The DMA is triggered byte the SPI TXE flag, the DR holding register​ is separate from the internal shift register that puts the data on the wire.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Thank you for rapid answer.