Skip to main content
Visitor II
November 6, 2025
Question

USB VDD issue

  • November 6, 2025
  • 2 replies
  • 222 views
We are using the STM32H7R7L8H6H microcontroller in our product design.
During firmware initialization, we observed inconsistent behavior related to the USB voltage detector on different boards that share the same hardware design and firmware.
Specifically, the following code auto generated by STM32Cube ide (stm32h7rsxx_hal_msp.c), this causes the MCU to halt on certain boards:
if (HAL_PWREx_EnableUSBVoltageDetector() != HAL_OK)
{ 
 Error_Handler();
}
 
On some boards, the code runs normally, but on others, it enters Error_Handler() immediately after executing this function.
Both boards have identical hardware configuration — USB is not used, and VDD33USB and VDD50USB are tied to 3.3 V.
- Advise whether disabling the USB voltage detector is the recommended workaround when USB is not used.
- Provide any official ST guidance or firmware-level / Hardware level workaround for this behaviour.
USBVDD.png

Should we modify the voltage level on the VDDUSB pin, or adjust the mounting status of the 0-ohm resistor instead? please see attached image.
- Should we comment above line permanently, in that case this lines will auto generated when moodifying .ioc file.
@Mehulrana511 

Edited to apply source code formatting - please see How to insert source code for future reference.

    This topic has been closed for replies.

    2 replies

    Super User
    November 6, 2025

    This shouldn't even compile. HAL_PWREx_EnableUSBVoltageDetector does not return a type.

    stm32h7xx-hal-driver/Src/stm32h7xx_hal_pwr_ex.c at d649ed2c7784bfbef4be144e7bfd8dbb41dce5c3 · STMicroelectronics/stm32h7xx-hal-driver

     

    If CubeMX is generating this, it's a bug in CubeMX. Please attach your IOC file.

    Super User
    November 6, 2025

    @TDK wrote:

    This shouldn't even compile. HAL_PWREx_EnableUSBVoltageDetector does not return a type.


    But, in an expression, the function still has a value - which is its address.

    So it should compile - but it won't do what's intended!

     


    @TDK wrote:

    If CubeMX is generating this, it's a bug in CubeMX. 


    Agreed!

    Super User
    November 6, 2025

    A void function does not return a value and cannot be used in an expression.

    Its value is not its address--that's nonsense.

    TDK_0-1762445792873.png

     

    Technical Moderator
    November 6, 2025

    Hi @Kaushik1 

    Would you increase the PWR_FLAG_SETTING_DELAY : e.g. multiply it by 10 to see if the issue persists?

    For STM32H7RS, when USB is not used, you can connect VDD33USB to 0 V to minimize any possible leakage. Also, USB33DEN should be set if a GPIO on port M is used.

    It is mentioned in this knowledge base article.