cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7R3 USB FS device enumeration problem

mkrk
Associate III

Dear ST,

I'm trying to get USB CDC device working on custom STM32H7R3L8HxH based board. Host (Windows) detects it but unfortunately the USB device fails to enumerate with error:

Windows has stopped this device because it has reported problems. (Code 43)
A request for the USB device descriptor failed.

USB FS based Boot ROM works in DFU mode so I know hardware should be okay.

I found a bug in CubeMX code generator. USBPHY clock source is configured to be HSE (which is 24 MHz):

mkrk_0-1756912658908.png

However code generator creates usbd_conf.c function HAL_PCD_MspInit with these lines:

  /** Initializes the peripherals clock
  */
    PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USBOTGFS;
    PeriphClkInit.UsbOtgFsClockSelection = RCC_USBOTGFSCLKSOURCE_PLL3Q;
    if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
    {
      Error_Handler();
    }

 

I confirmed with debugger in SFR view that indeed OTGFSSEL bits in RCC_CCIPR1 are set to PLL3/Q.

STM32CubeIDE version is 1.19.0 and MxCube version is 6.15.0.

Unfortunately manually fixing clock to HSE did not make it work. So there is probably another problem.

USB settings are:

mkrk_1-1756913245041.png

mkrk_2-1756913261908.png

mkrk_3-1756913284132.png

mkrk_5-1756913361500.png

mkrk_6-1756913374013.png

Only change in code is calling USBD_Start() after USB has been initialized in MX_USB_DEVICE_Init.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
mkrk
Associate III

Hi @FBL 

I checked discovery kit (DK) USB device example (mass storage). But I don't use USB HS and power delivery (PD) (yet) so that code didn't help much. But after comparing CDC code to mine and wondering about that HSE / PLL3Q issue I found the problem. I was configuring USBPHYC clock source (orange box) but not the OTG FS clock source (red box). The code generator in HAL_PCD_MspInit was setting up OTG FS clock and it was PLL3Q at 200 MHz which obviously doesn't work.

mkrk_1-1756978193533.png

So no problem with code generator, it was my fault.

After choosing USBPHY48 as source for OTG FS I got stuck at core reset issue, but for that I found cure from your post here: https://community.st.com/t5/stm32-mcus/faq-troubleshooting-a-usb-core-soft-reset-stuck-on-an-stm32/ta-p/803224

So, double the thanks!

 

 

View solution in original post

2 REPLIES 2
FBL
ST Employee

Hi @mkrk 

Did you refer to this example

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.


mkrk
Associate III

Hi @FBL 

I checked discovery kit (DK) USB device example (mass storage). But I don't use USB HS and power delivery (PD) (yet) so that code didn't help much. But after comparing CDC code to mine and wondering about that HSE / PLL3Q issue I found the problem. I was configuring USBPHYC clock source (orange box) but not the OTG FS clock source (red box). The code generator in HAL_PCD_MspInit was setting up OTG FS clock and it was PLL3Q at 200 MHz which obviously doesn't work.

mkrk_1-1756978193533.png

So no problem with code generator, it was my fault.

After choosing USBPHY48 as source for OTG FS I got stuck at core reset issue, but for that I found cure from your post here: https://community.st.com/t5/stm32-mcus/faq-troubleshooting-a-usb-core-soft-reset-stuck-on-an-stm32/ta-p/803224

So, double the thanks!