cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to flush the RX Fifo buffer in USB for STM32H747 micocontroller

Rushali
Associate III

Hello All,

 

Need your support regarding flushing of RX FIFO buffer in STM32H747.I am using a barcode reader which is connected to USB HS port . And i want to clear the received data from the buffer at particular instance. And after that instance want to read the buffer again. Can anyone please suggest how can i do it.

I have tried multiple method ,and i have mentioned all of them below:-

1. Using Inbuild function in STM32 USB Library file.

USB_FlushRxFifo(hhcd_USB_OTG_HS.Instance);

 

2.Masking the RXFLVLM bit from GINTMSK Register.

hhcd_USB_OTG_HS.Instance->GINTMSK &=~ ((0x1UL << (4U)));

 

3.Disabling the GINTMSK bit in GAHBCFG Register

hhcd_USB_OTG_HS.Instance->GAHBCFG &=~ ((0x1UL << (0U)));

 

4. Setting Core soft reset bit in GRSTCTL

hhcd_USB_OTG_HS.Instance->GRSTCTL |= USB_OTG_GRSTCTL_CSRST;

 

5. Deiniting & initing the USB device using inbuild functions from STM32.

USBH_DeInit(&hUSBHostHS);

USBH_Init(&hUSBHostHS, HID_USBH_UserProcess, HOST_HS);

 

the only method which worked was method 5 but it is taking longer than expected duration.

Can any body suggest is there any other way to Flush the RX fifo Buffer.

 

1 REPLY 1
FBL
ST Employee

Hi @Rushali 

First, core soft reset bit in GRSTCTL is read only.

 

Second, you can manipulate the received data the buffer by software because it's quite complex to flush rx fifo. According to the reference manual, this should be feasible. The LL USb driver already waits for AHB IDLE state to ensure no ongoing AHB transactions. Then, it sets RXFFLSH bit. After that it waits till it gets cleared by controller.FBL_0-1750098148789.png

Timeout value could be redefined based on your system's clock speed. 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.