cancel
Showing results for 
Search instead for 
Did you mean: 

Ringbuffer as shiftregister

DJMicro
Visitor

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 ?

 

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Super User

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".

View solution in original post

1 REPLY 1
TDK
Super User

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".