2025-02-18 06:45 AM
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!
2025-02-18 07:04 AM
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.).
2025-02-18 07:48 AM
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.
2025-02-18 04:25 PM - edited 2025-02-18 04:35 PM
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]