Skip to main content
YoungKim
Associate II
Feb 23, 2023 12:36 AM UTC
Question

Best way to handle SPI TX when using DMA RX in SPI slave in STM32F767

I have studied how to use SPI DMA.

The examples from STM32 project shows independent TX/RX.

I need to handle the 16-bit data as a register. When the slave receives 16-bit data, it should echo it right away for example.

​

Now I can receive DMA RX transmission complete interrupt.

This is RX handler:

void DMA2_ReceiveComplete_Callback()
{
 spi1_tx = spi1_rx;
 LL_SPI_TransmitData16(SPI1, spi1_tx);
 LL_DMA_SetDataLength(DMA2, LL_DMA_STREAM_0, 1);
 LL_DMA_EnableStream(DMA2, LL_DMA_STREAM_0);
}

This way works well. To send the data whenever it receives 16-bit data, it echo in its next turn. Is this good way to send data? Is there any better or faster way?

​

These are SPI1 configuration:

0693W00000aHSkUQAW.png0693W00000aHSkPQAW.png 

0693W00000aHSkjQAG.png

This topic has been closed for replies.