2018-09-21 12:53 AM
Hello. I am using STM32F407VG controller. I have to transfer data from another device via SPI interface. STM32 SPI is used in slave mode, circular DMA enabled. Devices are connected via joint.
In some cases I need to resynchronize data exchange. At this moment SPI master device stops data exchange for some time (clock is stopped, CS is high). SPI slave (STM32F407VG) after some time tried to stop SPI (HAL_SPI_Abort(&hspi1); ) and then restart SPI with circular DMA again.
But after this operation other side (SPI master) receive one unnecessary byte. This byte have been transferred by DMA to SPI TX buffer before transaction is stopped. How to remove this byte from SPI TX buffer before start transaction. I tried to disable SPI, disable SPI pheripheral clock, but nothing help.
I have an idea to disable GPIO and switch SPI to master mode. Is there another way possible? May be unreferenced register to reset spi buffer or spi module exists.
Solved! Go to Solution.
2022-03-05 01:10 AM
Thank you for saving my day!
2022-10-19 01:29 PM
hi! on the M0 + core, it worked for me only like this:
HAL_SPI_DMAStop(&hspi1);
__HAL_RCC_SPI1_FORCE_RESET();
__HAL_RCC_SPI1_RELEASE_RESET();
MX_SPI1_Init();