cancel
Showing results for 
Search instead for 
Did you mean: 

USB CoreReset stuck at count

Maaz1
Associate II

Hi all

 

static HAL_StatusTypeDef USB_CoreReset(USB_OTG_GlobalTypeDef *USBx)
{
  __IO uint32_t count = 0U;

  /* Wait for AHB master IDLE state. */
  do
  {
    count++;

    if (count > HAL_USB_TIMEOUT)
    {
      return HAL_TIMEOUT;
    }
  } while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_AHBIDL) == 0U);

  count = 10U;

  /* few cycles before setting core reset */
  while (count > 0U)
  {
    count--;
  }

  /* Core Soft Reset */
  USBx->GRSTCTL |= USB_OTG_GRSTCTL_CSRST;

  do
  {
    count++;

    if (count > HAL_USB_TIMEOUT)
    {
      return HAL_TIMEOUT;
    }
  } while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_CSRST) == USB_OTG_GRSTCTL_CSRST);

  return HAL_OK;
}

 

at the USB_CoreReset function, my code keeps on getting stuck at the count++ and doesn't progress from there. 

I have even included 

 
  RCC->AHB2ENR1 |= RCC_AHB2ENR1_OTGEN;        // enable USB OTG HS clock
    RCC->AHB2ENR1 |= RCC_AHB2ENR1_USBPHYCEN;   // enable ULPI clock

 

before that function call but it does nothing.
My board is stm32u5g9.

Thank you and kind regards

 

0 REPLIES 0