2025-10-06 7:40 PM - last edited on 2025-10-10 3:41 AM by mƎALLEm
HAL_PWREx_EnableUSBVoltageDetector();/* Configure VBUS Pin */
GPIO_InitStruct.Pin = GPIO_PIN_9;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);Solved! Go to Solution.
2025-10-10 4:22 AM - edited 2025-10-10 4:22 AM
Hello, @JE2
Can you specify whether the USB device is bus-powered or self-powered? and if self-powered , can you provide the GPIO pin that you are using?
Because based on AN4879section 2.6
a USB device must use VBUS sensing detection. There are two cases:
However, I tried replicating your case on my end, and I did not encounter any problems. I am attaching the project in case it can help you.
Gyessine
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-10-10 4:22 AM - edited 2025-10-10 4:22 AM
Hello, @JE2
Can you specify whether the USB device is bus-powered or self-powered? and if self-powered , can you provide the GPIO pin that you are using?
Because based on AN4879section 2.6
a USB device must use VBUS sensing detection. There are two cases:
However, I tried replicating your case on my end, and I did not encounter any problems. I am attaching the project in case it can help you.
Gyessine
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-10-13 5:36 PM
Thank you Gyessine!
It worked!
I ported just a following point from "H755_CDC.zip".
In usbd.conf
My original code(This is STM32Cube's code(STM32Cube_FW_H7_V1.11.0) as is, unchanged.)
/**
* @brief Suspend callback.
* @PAram hpcd: PCD handle
* @retval None
*/
void HAL_PCD_SuspendCallback(PCD_HandleTypeDef * hpcd)
{
USBD_LL_Suspend(hpcd->pData);
}
Gyessine's solution
void HAL_PCD_SuspendCallback(PCD_HandleTypeDef * hpcd)
{
USBD_LL_Suspend(hpcd->pData);
__HAL_PCD_GATE_PHYCLOCK(hpcd);
/* Enter in STOP mode. */
/* USER CODE BEGIN 2 */
if (hpcd->Init.low_power_enable)
{
/* Set SLEEPDEEP bit and SleepOnExit of Cortex System Control Register. */
SCB->SCR |= (uint32_t)((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk));
}
/Thanks!
2025-10-13 5:52 PM - edited 2025-10-14 2:32 AM
I didn't answer the Gyessine's question.
I'm developing a self-powered device.
The pins used for USB are:
You wrote this configuration requires VBus sensing.
Now I'm using Nuclueo-H755ZI-Q. This board has its VBus pin(PA9) physically connected.
I will check again when I get our prototyped board.