cancel
Showing results for 
Search instead for 
Did you mean: 

Clearing the SPI Buffer

Konami
Senior

Hi all, I'm working on a project where I am using an STM32F3 (master) to communicate with an STM32G0 (slave) using SPI with DMA. The G0 performs a task and can receive commands, and have it's "registers" (ie. state data) read out over the SPI.

I want the G0 to act as a peripheral device who's data can be read at any time. To accomplish this, I keep 2 buffers on the G0 containing the state data. Anytime there's new information I update the inactive buffer and pass that to the SPI DMA.

The problem I'm facing is that it seems the SPI has some buffered data, since it will transmit the last few bytes of the previous buffer before sending the correct data. This also means that my SPI read is missing the last few bytes of the current buffer. This issue seems to go away if I wait for a SPI read to occur before updating the buffer, but since the reading happens asynchronously, I need to be able to have the latest data at the ready at all times with minimal overhead and this is not an option.

I see a number of other posts regarding similar topics with no answer. The only generally accepted solution appears to be to reset, and re-initialize the SPI interface, which again is not an option since I would be burning too many cycles, doing this and the SPI would be down too long.

Is there a solution to this?

0 REPLIES 0