Skip to main content
Explorer
October 8, 2025
Solved

Ringbuffer as shiftregister

  • October 8, 2025
  • 1 reply
  • 216 views

At STM32G431 Is it possible to make a  (SPI daisy chain) shift register with one cyclic ringbuffer.

With SPI peripheral as Full duplex Slave, with 2 DMA (RX TX) channels. 

"HAL_SPI_TransmitReceive_DMA(SPI_GetHandle(), ringbuffer, ringbuffer, SPI_size); "

And stop DMA once NSS external pin interrupt accors ( rising edge).

 

Or in other words read and write to same buffer in dma is that possible?

I tested and it was working. Is this lucky or indeed possible, because SPI Transmit (read from buffer[x]) always happens before receiving (write in buffer[x]) from same index and therefore always guaranteed it works ?

 

Best answer by TDK

Yes, you can read and write to the same buffer. TXE is serviced first, so you will transmit the current content of the buffer and later receive data coming in. Writing only occurs after RXNE, which can only happen after the byte is already transmitted.

1 reply

TDK
TDKBest answer
Super User
October 8, 2025

Yes, you can read and write to the same buffer. TXE is serviced first, so you will transmit the current content of the buffer and later receive data coming in. Writing only occurs after RXNE, which can only happen after the byte is already transmitted.

"If you feel a post has answered your question, please click ""Accept as Solution""."