cancel
Showing results for 
Search instead for 
Did you mean: 

Debugging for Nucleo-H7S3L8 USB implementation

yamamo2shun1
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions
FBL
ST Employee

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 Accept as Solution on the reply which solved your issue or answered your question.


View solution in original post

2 REPLIES 2
FBL
ST Employee

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 Accept as Solution on the reply which solved your issue or answered your question.


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!