Skip to main content
Graduate
December 22, 2024
Solved

STM32H7S78 USB CoreReset timeout

  • December 22, 2024
  • 5 replies
  • 1909 views

Hey All, 
Similar issue to this previous topic,

I'm running into a timeout error every time I try and call  USBx->GRSTCTL |= USB_OTG_GRSTCTL_CSRST from the USB_CoreReset function in the example code. 

It seems like the previous solution was to make sure that a specific bit in the RCC section was enabled. But, that seems to be for the F3/U5 series of MCUs, and the H7 doesn't have that particular register or bit, it seems that the RCC is controlled a little bit differently. 

I've attached my register view, with a few of the RCC registers that might be of interest expanded. 
It might also be something that's not part of the RCC causing the issue, so I thought it wise to just include everything, incase there's something else in my project causing trouble. We haven't done a full clock analysis on this project yet, but it's on the to-do list.

Thanks,
-Hal 

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

    Hi @halfordC 

    Are you using ST reference board? This issue could be due to several reasons. It is possible the issue is linked to your PHY rooting's if using custom board, Otherwise It is firmware implementation. First, check HAL MSP init.

     if(HAL_PWREx_EnableUSBVoltageDetector() != HAL_OK)
     {
     /* Initialization error */
     Error_Handler();
     }
    
     HAL_PWREx_EnableUSBHSregulator();

    You need to verify power supply. The PHYs are supplied from a dedicated VDD33USB supply. This supply can be provided either by the integrated USB regulator or by an external USB supply. So, your code depends on your HW implementation.
    After configuring peripheral clock you should reenable voltage detector HAL_PWREx_EnableUSBVoltageDetector

     /** Enable USB Voltage detector */
     HAL_PWREx_EnableUSBVoltageDetector();
    
     /* Peripheral clock enable */
     __HAL_RCC_USB_OTG_HS_CLK_ENABLE();
     __HAL_RCC_USBPHYC_CLK_ENABLE();
    
     /* Peripheral interrupt init */
     HAL_NVIC_SetPriority(OTG_HS_IRQn, 6, 0);
     HAL_NVIC_EnableIRQ(OTG_HS_IRQn);

    Refer to the example provided STM32CubeH7RS/Projects/NUCLEO-H7S3L8/Applications/USB_Device at main · STMicroelectronics/STM32CubeH7RS

    5 replies

    Explorer
    January 16, 2025

    Hello, is there any solution to this problem? I have the same problem but on STM32H7R7L8

    FBLAnswer
    Technical Moderator
    January 17, 2025

    Hi @halfordC 

    Are you using ST reference board? This issue could be due to several reasons. It is possible the issue is linked to your PHY rooting's if using custom board, Otherwise It is firmware implementation. First, check HAL MSP init.

     if(HAL_PWREx_EnableUSBVoltageDetector() != HAL_OK)
     {
     /* Initialization error */
     Error_Handler();
     }
    
     HAL_PWREx_EnableUSBHSregulator();

    You need to verify power supply. The PHYs are supplied from a dedicated VDD33USB supply. This supply can be provided either by the integrated USB regulator or by an external USB supply. So, your code depends on your HW implementation.
    After configuring peripheral clock you should reenable voltage detector HAL_PWREx_EnableUSBVoltageDetector

     /** Enable USB Voltage detector */
     HAL_PWREx_EnableUSBVoltageDetector();
    
     /* Peripheral clock enable */
     __HAL_RCC_USB_OTG_HS_CLK_ENABLE();
     __HAL_RCC_USBPHYC_CLK_ENABLE();
    
     /* Peripheral interrupt init */
     HAL_NVIC_SetPriority(OTG_HS_IRQn, 6, 0);
     HAL_NVIC_EnableIRQ(OTG_HS_IRQn);

    Refer to the example provided STM32CubeH7RS/Projects/NUCLEO-H7S3L8/Applications/USB_Device at main · STMicroelectronics/STM32CubeH7RS

    halfordCAuthor
    Graduate
    January 20, 2025

    Thank you so much for the reply! 

    For clarity, I am using the stm32H7S78-DK dev kit. 
    The piece of code missing was the voltage regulator step inside of the HAL_MspInit function. 

    I also went ahead and changed my clock configuration around so that my template I'm working from matches the Dual class example, using the external crystal for system clock instead of the internal one.

    But yeah, seems to be just some missing code on the MSP Init function. Thanks again!

    Technical Moderator
    January 20, 2025

    Hi @halfordC @Shpegun60 

    Internal ticket is submitted to CubeMX team to include enable USB regulator in code generated (200802)

    Technical Moderator
    February 27, 2025

    Hi @halfordC 

    It seems we missed to add this "hidden" tricky checkbox in IOC file, 

    FBL_0-1740684522853.png