cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4xx - the previously connected android USB accessory isn't connect after board power on

Edward.P
Associate II

I have next trouble:

  1. stm32f407vgt6 mcu on my diy board with realized OTG_FS USB host and Android accessory application, that have connecting succesfull to it;
  2. After connect cable to board all working perfectly: connection and enumerates succesfully;
  3. If cable is stay in place and to turn mcu power off, then when i turn mcu power is on, connect is not reastablished as the bit PCSTS in registry of OTG_FS_HPTR not initialize;
  4. Note: that if ST-LINK V2 is connected to the SWD pins and 3.3V goes from it with the same manipulations, the connection occurs normally.

The board was not made by me and there is a suspicion that the series resistors in the D + and D- circuit do not correspond to the datasheet: they cost 10 ohms instead of 22.

Any help please.

4 REPLIES 4

How is the connected device powered? Is it powered when the problem occurs? Can you switch off/on its VBUS?

Measure voltage on DP/DM. USB host pulls down DP/DM by a nominally 15kOhm resistor; USB host detects connection when the device pulls up one of these line by a nominally 1k5 resistor, so this is easily seen on DP/DM.

JW

How is the connected device powered?

-- from self battery - is a smart phone and take a power charge from board STM32 where usb host build

Is it powered when the problem occurs?

-- yes

Can you switch off/on its VBUS?

-- no, the pin PA9 used as UART1_TX

Measure voltage on DP/DM.

-- any condition: connected and not connected - 770-800mV

USB host pulls down DP/DM by a nominally 15kOhm resistor; USB host detects connection when the device pulls up one of these line by a nominally 1k5 resistor, so this is easily seen on DP/DM.

-- i know. I'm try using code with pull-down resistor before USB_Init aka

do {
 		GPIO_InitTypeDef GPIO_InitStruct;
 		GPIO_InitStruct.GPIO_Pin = GPIO_Pin_12;
 		GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
 		GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_DOWN;
 
		GPIO_Init(GPIOA, &GPIO_InitStruct);
 	} while(0);

...not working

I get debug log from USB stack.

The success connect (with connected ST-LINK) looking as:

D 17:54:42 USB.cpp#66 USB constructor
D 17:54:42 USB.cpp#72 USB host init
>    AndroidAccessory inited..
>    Device Disconnected..
DEBUG :       --------Start USBH_LL_Init..
      --------Start HAL_HCD_Init success..
USBH_LL_DriverVBUS(), state: 1
>    ----Handle Host Port Interrupts..
>    ----HCD_Port_IRQHandler..
>    ---------- (hprt0 & USB_OTG_HPRT_PCDET) == USB_OTG_HPRT_PCDET..
>    ---------- (hprt0 & USB_OTG_HPRT_PCSTS) == USB_OTG_HPRT_PCSTS..
DEBUG : >    USBH_LL_Connect..
>    ----USB connected..
>    USB Device connected
>    ----Handle Host Port Interrupts..
>    ----HCD_Port_IRQHandler..
>    ---------- (hprt0 & USB_OTG_HPRT_PENCHNG) == USB_OTG_HPRT_PENCHNG..
>    ---------- (hprt0 & USB_OTG_HPRT_PENA) == USB_OTG_HPRT_PENA..

and fail connect strings looking as:

D 17:57:14 USB.cpp#66 USB constructor
D 17:57:14 USB.cpp#72 USB host init
>    AndroidAccessory inited..
>    Device Disconnected..
DEBUG :       --------Start USBH_LL_Init..
      --------Start HAL_HCD_Init success..
(... no connection after power on)
(..and tryed to reconnect with button that run pull down resistor code)
USBH_LL_DriverVBUS(), state: 0
>    Device Disconnected..
>    AndroidAccessory inited..
>    Device Disconnected..
DEBUG :       --------Start USBH_LL_Init..
      --------Start HAL_HCD_Init success..
DEBUG : >    ----DPPullDown..
DEBUG : >    ----USB GPIO_Pin_12 reset..
>    ----Handle Host Port Interrupts..
>    ----HCD_Port_IRQHandler..
>    ---------- (hprt0 & USB_OTG_HPRT_PCDET) == USB_OTG_HPRT_PCDET..
USBH_LL_DriverVBUS(), state: 1
 
... no connection USB device

And VBUS is freeing from level measurement with bun VBUS (VBUS sensing) options -- the set NOVBUSSENS bit in OTG_FS_GCCFG registry..

The USB PHY contains the required pulldowns and they are switched on automatically when you enable the host on 'F4. You don't need to enable pulldown in GPIO.

700mV on both DP and DM means, that the device does not work as expected.

JW