2023-02-22 04:36 PM
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: