Skip to main content
ADoro.2
Associate III
September 2, 2021
Question

Clear SPI TX FIFO

  • September 2, 2021
  • 3 replies
  • 3488 views

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,

This topic has been closed for replies.

3 replies

TDK
September 2, 2021

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
September 5, 2021

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

ACamu.2
Associate
March 29, 2022

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();