Skip to main content
Visitor II
February 14, 2025
Solved

VBUS Sensing STM32F107RCT6

  • February 14, 2025
  • 1 reply
  • 497 views

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.

Immagine 2025-02-14 024647.png

    This topic has been closed for replies.
    Best answer by FBL

    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

     

    1 reply

    FBLAnswer
    Technical Moderator
    February 27, 2025

    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