Skip to main content
Explorer
June 1, 2025
Solved

STM32u5g9 usb support

  • June 1, 2025
  • 2 replies
  • 398 views

Hello, I have been trying to implement USB support on an STM32u5g9vjt6Q using USBX in standalone mode without success as of yet. I have been referencing this guide (How to implement USBX in standalone mode ) I am trying to use the onboard USB Phy in full speed mode, I think my issue comes down to clock configuration.  I am able to perform a USB DFU firmware update through the onboard ST bootloader so I am fairly certain I do not have a hardware issue, I also have a 16mhz external crystal.

My firmware will end up in a Error_Handler after a timeout, the timeout is happening during this block of code inside of USB_CoreReset()

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

Debugging shows GRSTCTL = 0x80000001, CSRST = 0x1

I will attach a picture of the call stack w/ the section of code and the contents of the register.  I will also attach the CubeIDE project.
Screenshot_20250601_160300.png
Thanks!

    This topic has been closed for replies.
    Best answer by brohr01

    After many hours scouring these forums and trying everything I could find I finally got it working.  It all came down to 1 missing function call that was not generated by cubeMX or part of the usbx standalone guides I was following.  I added the following call after the clocks are configured but before MX_USBX_DEVICE_Init is called. I placed this inside of the USER CODE BEGIN SysInit section

    __HAL_RCC_SYSCFG_CLK_ENABLE();

     

    2 replies

    brohr01AuthorAnswer
    Explorer
    June 2, 2025

    After many hours scouring these forums and trying everything I could find I finally got it working.  It all came down to 1 missing function call that was not generated by cubeMX or part of the usbx standalone guides I was following.  I added the following call after the clocks are configured but before MX_USBX_DEVICE_Init is called. I placed this inside of the USER CODE BEGIN SysInit section

    __HAL_RCC_SYSCFG_CLK_ENABLE();

     

    Technical Moderator
    June 2, 2025

    Hi @brohr01 

    Glad you solved your issue. This FAQ: Troubleshooting a USB core soft reset stuck should be helpful in your case.