Skip to main content
Associate II
February 18, 2025
Question

STM32H7 optimized SPI driver for use in DMA mode

  • February 18, 2025
  • 3 replies
  • 1069 views

Good day everyone.

 

I am working on the STM32H7 MCU and using the HAL library for controlling an SPI in DMA mode that has to exchange data with an external device in real-time. I'm working at the maximum possible CPU frequency and using the -O2 optimization, and still, there is a 3.5 microseconds delay between the call of SPI_TransmitReceive_DMA and the SPI transfer start, and then, after the SPI transmission start there is around 1.5 microseconds delay before the function returns.

Does anyone have an optimized for performance SPI driver for use in DMA mode? 

I'm trying to avoid writing everything from scratch, so any input on this matter would be greatly appreciated!

This topic has been closed for replies.

3 replies

Michal Dudka
Lead
February 18, 2025

You probably have to write it yourself using LL API or "bare metal" if you need latencies under microsecond. How fast it can be depends on your use case (the whole DMA transfer can be started and handled fully autonomously using DMAMUX request generator etc.). 

TDK
February 18, 2025

Usually there's a way. If it's a periodic transfer of known duration and frequency, it can be set up to take 0 cpu cycles other than data processing, even with HAL.

Start with requirements and let those drive the implementation.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Pavel A.
February 19, 2025

IIRC there's "idleness" parameter that controls delay between SS active edge and starting the transfer.

 LL_SPI_SS_IDLENESS...  register SPI_CFG2 bits MSSI[3:0]