2024-12-22 02:15 PM
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
Solved! Go to Solution.
2025-01-17 08:39 AM
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
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.
2025-01-16 06:33 AM
2025-01-17 08:39 AM
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
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.
2025-01-19 07:02 PM
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!
2025-01-20 05:08 AM
Internal ticket is submitted to CubeMX team to include enable USB regulator in code generated (200802)
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.