2016-06-30 02:08 PM
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.1main.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
2016-07-01 03:46 AM
Hi chinzei.tsuneo,
Thank you for valuable feedback. I report this internally to our CubeMx team. -Hannibal-2016-10-06 07:41 AM
Dear user,
This issue is fixed starting from STM32CubeMX 4.16.
Best regards