1
votes

Does anyone have a sample code of transfering data with SPI in DMA CIRCULAR mode for stm32?(16 bit) With my code, master sends 16 bit data and in the next cycle receives the answer. But this transaction done with one cycle delay.

1

1 Answers

1
votes

SPI is supposed to work that way.

When the SPI data register is written the first time, it starts sending the data, and immediately signals the DMA controller that it's ready for the next data word. Now there are two data words down in the transmitter, when it has barely started receiving the first one. When the first outgoing word is completely transmitted, and the first incoming word is completely received (these happen almost simultaneously), SPI starts sending the second word already in the data register, signals the transmit DMA channel that it's ready for the third data word, about the same time it also signals the receiving channel that the first incoming data word is ready.

enter image description here