2025-11-06 5:04 AM - last edited on 2025-11-06 7:43 AM by Andrew Neil
if (HAL_PWREx_EnableUSBVoltageDetector() != HAL_OK)
{
Error_Handler();
}
Edited to apply source code formatting - please see How to insert source code for future reference.
2025-11-06 6:08 AM - edited 2025-11-06 6:10 AM
This shouldn't even compile. HAL_PWREx_EnableUSBVoltageDetector does not return a type.
If CubeMX is generating this, it's a bug in CubeMX. Please attach your IOC file.
2025-11-06 6:47 AM - edited 2025-11-06 7:52 AM
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.
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-11-06 7:48 AM
@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!
2025-11-06 8:16 AM
A void function does not return a value and cannot be used in an expression.
Its value is not its address--that's nonsense.
2025-11-06 8:52 AM
@TDK wrote:Its value is not its address--that's nonsense.
You're right - that only applies without the parentheses.
So the code @Kaushik1 presented can't be the real code