Skip to main content
Visitor II
March 13, 2021
Question

Callbacks for SPI in DMA mode

  • March 13, 2021
  • 1 reply
  • 1270 views

I have both TX and RX on SPI1 on a F407 running in DMA circular mode. In the HAL_SPI_TxRxCpltCallback I parse the data that I receive from the Pi (since the Pi and the STM32 communicate over SPI1).

Does the TxRx callback get called when BOTH, TX and RX are complete or when either is complete? Also, I tried starting the SPI for Tx and Rx in DMA mode but separately like this,

HAL_SPI_Transmit_DMA(&hspi1, rpi_tx, 55);
HAL_SPI_Receive_DMA(&hspi1, rpi_rx, 55);

And then defined separate RX and TX callbacks. But this does not seem to work and they do not trigger nor receive the data from the Pi. Is there a way to define two separate callbacks?

    This topic has been closed for replies.

    1 reply

    Graduate
    March 14, 2021

    I think you must use HAL_SPI_TransmitReceive_DMA... Data is transmitted and received synchronously to the master clk. TxRx callback ist called afterwards.