Skip to main content
Markus Rudolf
Associate III
March 15, 2017
Question

CubeMX V4.20: VBUS sensing always enabled in FS mode STM32F407

  • March 15, 2017
  • 3 replies
  • 1464 views
Posted on March 15, 2017 at 09:59

I discovered CubeMX 4.20 always generates code where VBUS sensing is enabled, no matter if it is ticked in CubeMX or not. This caused enumeration fails in several projects where PA9 is not used by me (I use it in CDC Virtual Com Port mode)

Affected code file is usbd_conf.c line 299 (line 18 in snippet)

USBD_StatusTypeDef USBD_LL_Init (USBD_HandleTypeDef *pdev)
{ 
 /* Init USB_IP */
 if (pdev->id == DEVICE_FS) {
 /* 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 = 4;
 hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL;
 hpcd_USB_OTG_FS.Init.dma_enable = DISABLE;
 hpcd_USB_OTG_FS.Init.ep0_mps = DEP0CTL_MPS_64;
 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.vbus_sensing_enable = ENABLE; // <= IT SHOULD BE DISABLED !!!
 hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = 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);
 }
 return USBD_OK;
}
�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

Took me a while. Please fix it, also fix the annoying RCC Init Bug and the 'does not build in STM32 System Workbench because we forgot to put the 'attribute weak' in hypens-bug'.

It is really annoying to correct this after each minor change in CubeMX.

Markus

#cube-mx #stm32cube-bug #usb-vbus
This topic has been closed for replies.

3 replies

Nesrine M_O
Associate
March 15, 2017
Posted on March 15, 2017 at 10:36

Hi

Rudolf.Markus

,

Thank you for your feedback. The issue has been reportedto our MX team for checking.

-Nesrine-

Markus Rudolf
Associate III
April 7, 2017
Posted on April 07, 2017 at 18:44

Is this by chance fixed in 4.20.1? The change log is basically worthless:

'Fixed regression in the management of peripherals parameters default value.'

That is so vacuous.

It would be really helpful to provide links to the discussed issues in the forum in the change log or provide some kind of bug tracking system for the CubeMX.

world04
Visitor II
April 21, 2017
Posted on April 21, 2017 at 22:03

I can agree this - it's not fixed yet.

Cyril FENARD
ST Employee
April 12, 2018
Posted on April 12, 2018 at 12:00

Hi

Rudolf.Markus

,

May you confirm that the problem is solved also your side?

Thanks in advance for helping to complete this thread.

Regards.

Cyril

Markus Rudolf
Associate III
April 12, 2018
Posted on April 12, 2018 at 12:06

I'm working on different projects right now, but I'm spinning a revision 2 of the affected board / firmware which is in production already. I will test then with the latest Cube and will report back. But it will take me some time.