2025-02-13 5:50 PM - edited 2025-02-13 5:53 PM
Good morning,
I am implementing a USB connection between my PC and the STM32F107 MCU in Device Only mode on a custom PCB. Since the PCB is powered through the USB connector (VBUS), I do not want to use the VBUS sensing pin (PA9) to activate USB communication. I have disabled it in the STM32CubeIDE settings, but the communication still does not start when I connect the cable.
The only way I found to initiate USB communication between the PC and the MCU is by setting PA9 as a GPIO OUTPUT Pull-Up. Is there a way to disable VBUS detection?
For reference, I am using the Middleware USB library with the Virtual COM Port (VCP) class. In the past, I used an STM32F411CEU6, and I did not encounter this issue—USB communication started immediately upon connecting the cable, even without VBUS being connected.
2025-02-27 12:57 AM
Hi @Schenna10
Any 5V tolerant pin with external interrupt functionality can be used with an external resistor divider, to fulfill AMR conditions. In this case, the recommended values are 2x100 kOhms.
The software needs to handle VBUS presence events.
/**
* @brief EXTI line detection callback
* @param GPIO_Pin: Specifies the pins connected EXTI line
*/
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
if (GPIO_Pin == VBUS_DETECT_Pin)
{
if (HAL_GPIO_ReadPin(VBUS_DETECT_GPIO_Port, VBUS_DETECT_Pin) == GPIO_PIN_SET)
{
MX_USB_Device_Init(); // reinitialize USB
}
else
{
USB_Device_DeInit(); // deinitialize USB
}
}
}
Check this article Management of VBUS sensing for USB device design - STMicroelectronics Community
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.