I am using Maple r5 board.
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, rarely, Slave needs to send data itself.
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, the first byte to be sent to Master is always from dummy value from 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?