cancel
Showing results for 
Search instead for 
Did you mean: 

Vbus is driven in mass storage mode.

VBarb.1
Associate II

This specifically relates to the same stm32l496 and the USB functionality, specifically creating mass storage mode. I used STMCubeMx to generate the configuration originally, and have since checked that against sample project provided by STM on github. The mass storage mode is working wonderfully. The issue appears to be when unplugged, the micro is driving the vbus line. This is making us unable to sense or detect if the vbus is detected or not. (I believe in mass storage we should be in device mode, not host mode so vbus should not be driven).

So the generated config is (located in usbd_conf.c):

USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev)

{

 /* Init USB Ip. */

 if (pdev->id == DEVICE_FS) {

 /* Enable USB power on Pwrctrl CR2 register. */

 /* Link the driver to the stack. */

 hpcd_USB_OTG_FS.pData = pdev;

 pdev->pData = &hpcd_USB_OTG_FS;

  hpcd_USB_OTG_FS.Instance = USB_OTG_FS;

 hpcd_USB_OTG_FS.Init.dev_endpoints = 1;

 hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL;

 hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED;

 hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE;

 hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE;

 hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE;

 hpcd_USB_OTG_FS.Init.battery_charging_enable = DISABLE;

 hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE;

 hpcd_USB_OTG_FS.Init.vbus_sensing_enable = DISABLE;

 if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK)

 {

   Error_Handler( );

 }

}

 HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_FS, 0x80);

 HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 0, 0x40);

 HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 1, 0x80);

 }

  • I’ve tried enabling and disabling other options such as vbus_sensing_enable.
  • Nothing will stop driving the vbus to at least 2.5 ish Volts. This also seems strange because it isn’t a true 3.3 or 5V.
  • I did verify that vbus is being initialized as an input. (have tried pulldown and “nopull�? as options).

0 REPLIES 0