cancel
Showing results for 
Search instead for 
Did you mean: 

Clear SPI TX FIFO

ADoro.2
Associate III

I`m working with STM32G0 and SPI in slave mode.

Is it possible to clear TX FIFO buffer without any master`s clock?

In HAL library there is a function called "HAL_SPIEx_FlushRxFIFO", but no method to clear TX FIFO,

3 REPLIES 3
TDK
Guru

There's no easy mechanism to clear TXFIFO. Force resetting the peripheral and reinitializing is reported to work on the F0 and other families. On the H7 family, resetting SPE clears the FIFO, but not here, per the RM.

https://community.st.com/s/question/0D50X00009XkeT8/stm32f0-spi-txfifo-flush

HAL_SPIEx_FlushRxFifo just reads out DR until it's empty, no special command or anything.

https://github.com/STMicroelectronics/STM32CubeG0/blob/5cb06333a6a43cefbe145f10a5aa98d3cc4cffee/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_spi_ex.c#L80

If you feel a post has answered your question, please click "Accept as Solution".
S.Ma
Principal

You need to use the peripheral reset control bit from RCC/SYS and reconfigure the spi...

ACamu.2
Associate

The HAL lets you do the RCC/SYS reset through some macros:

HAL_SPI_Abort(SPIxTypedef);
 
__HAL_RCC_SPI2_FORCE_RESET();
 
__HAL_RCC_SPI2_RELEASE_RESET();