Skip to main content
tsuneo
Associate II
June 30, 2016
Question

CubeMX bug: USB devices wrongly enable host power switch on Discovery boards

  • June 30, 2016
  • 2 replies
  • 962 views
Posted on June 30, 2016 at 23:08

As the USB host power switch, most of Discovery boards mount STMPS2141STR, whose Enable pin is active low. For USB device-only applications, CubeMX generates bad initialization code, which wrongly enables this power switch, in MX_GPIO_Init() (main.c)

- 5V rail of the board is supplied to the USB connector, at the VBUS pin. It conflicts with host 5V supply. - USB device application can't detect unplug from host. Discovery boards - STM32F4 Discovery - 32F401C Discovery - 32F411E Discovery - 32F429I Discovery - 32L476G Discovery - 32F746G Discovery (OTG_FS port) - maybe, more CubeMX: v4.1 (latest) CubeF7: v1.4.0 CubeF4: v1.0 CubeL4: v1.5.1

main.c
static void MX_GPIO_Init(void)
{
...
...
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(OTG_FS_PowerSwitchOn_GPIO_Port, OTG_FS_PowerSwitchOn_Pin, GPIO_PIN_RESET);
// <--- GPIO_PIN_SET, instead of GPIO_PIN_RESET, to disable the power switch

Tsuneo #usb #bug #stm32cube
This topic has been closed for replies.

2 replies

Walid FTITI_O
Visitor II
July 1, 2016
Posted on July 01, 2016 at 12:46

Hi chinzei.tsuneo,

Thank you for valuable feedback. I report this internally to our CubeMx team.

-Hannibal-

stm32cube-t
ST Employee
October 6, 2016
Posted on October 06, 2016 at 16:41

Dear user,

This issue is fixed starting from STM32CubeMX 4.16.

Best regards