AnsweredAssumed Answered

STM32 SPI DMA Timings

Question asked by Gábor Várkonyi on Feb 13, 2017
Latest reply on Jul 24, 2017 by waclawek.jan

Hello all,


I'm trying to setup the STM32L432 MCU for SPI communication (24 MHz, 16 bit data size, master transmit only), using DMA.

The slave device is a 32 channel amplifier chip. I need to send a specific string of bits only once at the start, to setup the registers on the slave device, and then continuously send another string of bits to let the slave know to keep sampling and cycling through its 32 channels, until it receives a stop command or powers down.

I've generated a code using CubeMx, with the appropriate parameters setup. I've been using the HAL_SPI_Transmit_DMA command to send the data. I'm getting the correct SCLK and MOSI signals however am not getting the correct timings between successive SCLK bursts. My two questions are:

  1. The timing between the successive SCLK bursts is too short when Circular DMA transmission is enabled (shown in screenshot)Channel 3 Pink SCLK, Channel 4 Green CS. I would need it to be roughly twice as big (about ~200 ns) Where can I control the timing of this? If I enable Normal DMA and put the HAL_SPI_Transmit_DMA command within a while loop I get the opposite problem, the gap between the successive SCLK bursts become too big, about 5 us.

  2. How could I setup two different DMA profiles to operate withing one script, and call them up when required? I would need this as the bit stream dataTx2 only needs to be sent once so would require DMA to be set to normal, while dataTx would needed to be sent continuously using circular DMA.

The code can be found here:

Thank you in advance,