cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F429 OTG_HS overwrites pinfunction in embedded PHY Mode

bve
Associate II
Posted on July 29, 2016 at 12:53

Dear all,

we just encountered a problem with a STM32F429NI based hardware. We are using USB_OTG_HS in full speed mode with the integrated PHY, while using PB13 as a digital input. At first PB13 behaves normal with internal pullup on a button and I can measure 3,3V on the IO. After initialization of the USB as virtual com port (init code generated by Cube MX), PB13 provides a constant voltage of 1,1V and cannot read another value than 0 on IDR Register. Debugging the application, I verified, that MODER register is set to input (00) for PB13, however after running over the lowlevel init of USB, the pin becomes unresponsive. It seems like the routine is activating OTG_HS_

ULPI_D6

without changing the MODER to alternative function. I can only explain the 1,1V as a mid-termination voltage when both pullup and pulldown are active on the port. It is externally connected to a dip switch, so there is no load on the line, as long as the switch stays off. This is the code snippet, that results in the wrong behaviour, it is in USBD_StatusTypeDef USBD_LL_Init (USBD_HandleTypeDef *pdev) of ST's USB Driver middleware and called by MX_USB_DEVICE_Init, generated by CubeMX:

hpcd_USB_OTG_HS.Instance = USB_OTG_HS;
hpcd_USB_OTG_HS.Init.dev_endpoints = 11;
hpcd_USB_OTG_HS.Init.speed = PCD_SPEED_FULL;
hpcd_USB_OTG_HS.Init.dma_enable = ENABLE;
hpcd_USB_OTG_HS.Init.ep0_mps = DEP0CTL_MPS_64;
hpcd_USB_OTG_HS.Init.phy_itface = USB_OTG_EMBEDDED_PHY;
hpcd_USB_OTG_HS.Init.Sof_enable = DISABLE;
hpcd_USB_OTG_HS.Init.low_power_enable = DISABLE;
hpcd_USB_OTG_HS.Init.lpm_enable = DISABLE;
hpcd_USB_OTG_HS.Init.vbus_sensing_enable = DISABLE;
hpcd_USB_OTG_HS.Init.use_dedicated_ep1 = DISABLE;
hpcd_USB_OTG_HS.Init.use_external_vbus = DISABLE;
HAL_PCD_Init(&hpcd_USB_OTG_HS);

Can anybody reproduce this problem? Is there a workaround to retain normal pin function, or might it be an error in the HAL or even silicon? #usb_otg_hs-pin-function-error
1 REPLY 1
dku
Associate
Posted on August 02, 2016 at 13:28

Good day everyone,

I'm a colleague of Björn. After looking around for a bit I was able to locate and fix the problem. It indeed seems to be an error in the HAL. Line 223 of stm32f4xx_ll_usb.c activates VBUS sensing on PB13 (and thus the pulldown as far as I can see) wether you set

hpcd_USB_OTG_HS.Init.vbus_sensing_enable

to

DISABLE

or

ENABLE

. That should only happen if it is set to

ENABLE

. If you now change Lines 223ff of stm32f4xx_ll_usb.c (V1.5.1) from:


USBx->GCCFG |= USB_OTG_GCCFG_VBUSBSEN;


if
(cfg.vbus_sensing_enable == 0U)

{

USBx->GCCFG |= USB_OTG_GCCFG_NOVBUSSENS;

}

to:


if
(cfg.vbus_sensing_enable == 0U)

{

USBx->GCCFG |= USB_OTG_GCCFG_NOVBUSSENS;

}

else

{

USBx->GCCFG |= USB_OTG_GCCFG_VBUSBSEN;

}

everything works as expected.