AnsweredAssumed Answered

How to clear SPI TX Buffer

Question asked by kim.ilhyoung on Jan 2, 2012
Latest reply on Jun 30, 2016 by wolff.roger

I am using STM32F103 MPU.

I set the board as SPI Slave and uses DMA to receive and send data.
Most of time Command comes from Master and Slave responses.

So I made code to wait for receiving Command from Master. Once Command is received, send response back to Master. This approach is working.

But, really trouble is that, rarely, Slave needs to send data to Master without command.

In that case, I disable DMA RX, TX buffer and canceled waiting Command.
After that, SPI is reinitiated with DMA RX, and TX buffer with new data to be sent to Mater.

When I took a look the signal log, the first byte to be sent to the Master is always from dummy value which was in previous waiting Command transaction.

Even I canceled waiting Command transaction, 1 byte still remains in TX buffer.
I tried to find a way how to clear TX buffer in STM32F103 reference manual, I couldn't find it.

Anybody has any idea how to clear TX buffer?

Outcomes