Skip to main content
Associate II
Jun 12, 2025 6:34 AM UTC
Solved

Debugging for Nucleo-H7S3L8 USB implementation

I am verifying USB implementation using Nucleo-H7S3L8.

When I executed CDC_Standalone in STM32CubeH7RS using the Debug button and ran the Appli code, the function “HAL_PWREx_EnableUSBVoltageDetector()” in ‘MX_USBPD_Init()’ did not return HAL_OK and an error occurred.Within this function, the “USB regulator ready flag (PWR_CSR2_USB33RDY)” is not set, causing a timeout and resulting in a HAL_ERROR.

However, when I stop debugging, disconnect the USB cable, and reconnect it, the COM port appears in the Windows Device Manager.

I have not made any changes to the contents of CDC_Standalone.
The jumper on JP3 on the board has been changed from STLINK to UCPD.

What should I do to properly debug USB on this board?

 

error.png

This topic has been closed for replies.
FBLBest answer
ST Technical Moderator
Jun 12, 2025 11:13 AM UTC

Hi @yamamo2shun1 

It seems the example is setting USB33DEN twice in HAL_Init() and in HAL_PCD_MspInit(). Ensure that you remove the redundant call to HAL_PWREx_EnableUSBVoltageDetector() from one of the locations to avoid unnecessary duplication.

According to the reference manual, USB33DEN bit should be set if USB HS, FS, or a GPIO on port M is used. USBHSREGEN should only be set if USB HS is used.

So, when simply using port M as GPIO, you should keep the call in HAL_Init(). Otherwise, you can keep it in PCD_MspInit().

This FAQ about voltage regulator, specifically section 2.2 STM32H7RS use case might explain some clock configuration as well.

About JP3, it is necessary in host mode, to ensure providing sufficient VBUS supply through external source.

To give better visibility on the answered topics, please click on "Best answer" on the reply which solved your issue or answered your question.Best regards,FBL

2 replies

FBLBest answer
ST Technical Moderator
Jun 12, 2025 11:13 AM UTC

Hi @yamamo2shun1 

It seems the example is setting USB33DEN twice in HAL_Init() and in HAL_PCD_MspInit(). Ensure that you remove the redundant call to HAL_PWREx_EnableUSBVoltageDetector() from one of the locations to avoid unnecessary duplication.

According to the reference manual, USB33DEN bit should be set if USB HS, FS, or a GPIO on port M is used. USBHSREGEN should only be set if USB HS is used.

So, when simply using port M as GPIO, you should keep the call in HAL_Init(). Otherwise, you can keep it in PCD_MspInit().

This FAQ about voltage regulator, specifically section 2.2 STM32H7RS use case might explain some clock configuration as well.

About JP3, it is necessary in host mode, to ensure providing sufficient VBUS supply through external source.

To give better visibility on the answered topics, please click on "Best answer" on the reply which solved your issue or answered your question.Best regards,FBL
Associate II
Jun 13, 2025 12:15 AM UTC

Hi @FBL 

Thank you for your advice and useful tips!

 


@FBL wrote:

It seems the example is setting USB33DEN twice in HAL_Init() and in HAL_PCD_MspInit(). Ensure that you remove the redundant call to HAL_PWREx_EnableUSBVoltageDetector() from one of the locations to avoid unnecessary duplication.

Commenting out HAL_PWREx_EnableUSBVoltageDetector() in HAL_Init() made it work properly!