cancel
Showing results for 
Search instead for 
Did you mean: 

SPI1 with DMA Overflow Issue

LMorr.3
Senior II

I have SPI1 setup as Receive Only Slave with DMA enabled.  I send 10 bytes from SPI2 ( to simulate a full duplex master uC )  and it works well the first time I transmit 10 bytes.  When I transmit 10 bytes a second time, SPI1's overflow flag gets set just after the transmit.  It works if I set SPI1's DMA to circular mode, but not in normal mode.  The SPI receive call has the correct SIZE ( 10 bytes ).

I have the slave interrupt when the master ( SPI2 ) toggles the SS pin to high and want to 'reset' the slave's SPI1 and DMA somehow so that it continues to work on the next packet transmission.

How do I reset SPI1's so that it works for concurrent transmissions?

5 REPLIES 5
RhSilicon
Lead

HAL code may take time to perform operations. It might be interesting to use two boards to check if the behavior is the same.

Tinnagit
Senior II

you should try to use STOP DMA and flush data in that DMA.
then START DMA again.

you should try it.

it's about DMA mechanism that if you use incremental in normal mode, the DMA can addressing to out of size of memory that you had configured. 

What is the correct way to stop dma, flush the data and start it up again?  Are there special commands I should use to make it work?  I read others have had issues.

I see info. about these but not sure if I should use them:

__HAL_RCC_SPI1_FORCE_RESET();

__HAL_RCC_SPI1_RELEASE_RESET();

 

HAL_SPI_DMAStop(&hspi1);

HAL_SPI_Init(&hspi1);

 

I'm not exactly sure for spi
HAL_SPI_DMAStop(&hspi1);
and Read it 
and then HAL_SPI_DMAStart(&hspi1); again
the reinitial is unnecessary.