cancel
Showing results for 
Search instead for 
Did you mean: 

Why USB_ResetPort function has 100 ms delay ?

NAgha.1
Associate II

USB_ResetPort function is called in USBH_Process in HOST_IDLE state after USBH_Delay(200U); this results in 300 ms delay usb application.

Is there any way to reduce this time in stm32 USB applications.

This function is after a USB connection.

Is there any way to remove this delays in USB_ResetPort funciton.

HAL_StatusTypeDef USB_ResetPort(USB_OTG_GlobalTypeDef *USBx)
{
  uint32_t USBx_BASE = (uint32_t)USBx;
 
  __IO uint32_t hprt0 = 0U;
 
  hprt0 = USBx_HPRT0;
 
  hprt0 &= ~(USB_OTG_HPRT_PENA | USB_OTG_HPRT_PCDET |
             USB_OTG_HPRT_PENCHNG | USB_OTG_HPRT_POCCHNG);
 
  USBx_HPRT0 = (USB_OTG_HPRT_PRST | hprt0);
  HAL_Delay(100U);                                 /* See Note #1 */
  USBx_HPRT0 = ((~USB_OTG_HPRT_PRST) & hprt0);
  HAL_Delay(10U);
 
  return HAL_OK;
}

 #[STM32 MCUs]​  #USB​ 

1 ACCEPTED SOLUTION

Accepted Solutions
MWB_CHa
ST Employee

Hi @NAgha.1​ ,

Some timings are forced by specification and by portability reasons.

We setup these timings following validation tests ran on multiple devices.

But if your host is going to support a specific device or specific range of devices that doesn't need this delay, then you can remove it or reduce it.

I hope it helps.

View solution in original post

1 REPLY 1
MWB_CHa
ST Employee

Hi @NAgha.1​ ,

Some timings are forced by specification and by portability reasons.

We setup these timings following validation tests ran on multiple devices.

But if your host is going to support a specific device or specific range of devices that doesn't need this delay, then you can remove it or reduce it.

I hope it helps.