cancel
Showing results for 
Search instead for 
Did you mean: 

Can't power off USB VBUS with USB HAL driver in USB Host mode

PHlin.1
Associate III

Hello,

I'm using STM32H747I-DISCO Discovery kit with STM32Cube_FW_H7_V1.6.0 and currently doing some USB testing. So far everything works fine and I was able to get to work everything I needed, but I'm unable to turn off external VBUS. The board contains external PHY USB3320C chip which controls the VBUS. From what I found so far this power is controlled with this function

HAL_StatusTypeDef USB_DriveVbus(USB_OTG_GlobalTypeDef *USBx, uint8_t state)
{
  uint32_t USBx_BASE = (uint32_t)USBx;
  __IO uint32_t hprt0 = 0U;
 
  hprt0 = USBx_HPRT0;
 
  hprt0 &= ~(USB_OTG_HPRT_PENA | USB_OTG_HPRT_PCDET |
             USB_OTG_HPRT_PENCHNG | USB_OTG_HPRT_POCCHNG);
 
  if (((hprt0 & USB_OTG_HPRT_PPWR) == 0U) && (state == 1U))
  {
    USBx_HPRT0 = (USB_OTG_HPRT_PPWR | hprt0);
  }
  if (((hprt0 & USB_OTG_HPRT_PPWR) == USB_OTG_HPRT_PPWR) && (state == 0U))
  {
    USBx_HPRT0 = ((~USB_OTG_HPRT_PPWR) & hprt0);
  }

When the HAL driver call

(void)USB_DriveVbus(hhcd->Instance, 1U);

Than the VBUS is powered on, but when the VBUS is on and I add to the code

(void)USB_DriveVbus(hhcd->Instance, 0U);

Nothing happened and there is still +5V on the USB port. Is there something else I have to do to power off the USB port? I would appreciate any help.

Thanks,

Petr

2 REPLIES 2
dbgarasiya
Senior II

your usb is getting power with this pin

PHlin.1
Associate III

Hi,

Thanks for your reply, I'm working on USB Host application and need to power off the USB device by turning off external VBUS. I'm not sure that I understand your answer. Maybe it wasn't obvious that I'm talking about Host mode, I updated the title.