Skip to main content
PHlin.1
Associate III
Jan 30, 2020 7:10 PM UTC
Question

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

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

This topic has been closed for replies.

2 replies

dbgarasiya
Senior
Feb 3, 2020 12:17 PM UTC

your usb is getting power with this pin

PHlin.1
PHlin.1Author
Associate III
Feb 3, 2020 12:48 PM UTC

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.