cancel
Showing results for 
Search instead for 
Did you mean: 

SPI with DMA - little problem

Grzegorz Kania
Associate III
Posted on February 08, 2018 at 10:03

Is there any posisibilities to clear SPI FIFO before calling to HAL_SPI_Receive_DMA ? If We don't do it than we get old data in read buffer. I found  that only way to do it, is reading RX so many times, as the fifo is deep.

What are you thinking about that: clearing of the contents of fifo should be a first part of HAL_SPI_Receive_DMA function ?

Regards

Grzegorz Kania

4 REPLIES 4
T J
Lead
Posted on February 08, 2018 at 11:28

do you want to empty the SPI receiver ?

while( !(SPI1->SR & SPI_I2S_FLAG_RXNE) )

   dumpMe =SPI1->DR;                                 // empty receiver

Grzegorz Kania
Associate III
Posted on February 08, 2018 at 12:48

Thank you. I know this solution.:)

But I'm thinking over something, where I have to do only one command.

Posted on February 09, 2018 at 13:57

My problem is more serious.

If spi receiver not recive a complete data, than the receiving of next data will be corrupted.

It such could happen  for example as result of EMC distortion.

How to repair that situation, when we have no posibilities to reset the state of receiver ?

Regards

Grzegorz

Posted on February 09, 2018 at 15:15

Simply disable and re-enable the SPI interface.