2023-08-21 05:26 PM
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?
2023-08-22 12:47 AM
HAL code may take time to perform operations. It might be interesting to use two boards to check if the behavior is the same.
2023-08-22 02:08 AM
you should try to use STOP DMA and flush data in that DMA.
then START DMA again.
you should try it.
2023-08-22 02:10 AM
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.
2023-08-22 04:09 AM - edited 2023-08-22 04:09 AM
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);
2023-08-22 05:29 AM
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.