Skip to main content
Olov Ros�n
Associate
May 17, 2017
Solved

Cannot de-initialize USB Host pull down on STM32F407

  • May 17, 2017
  • 3 replies
  • 2440 views
Posted on May 17, 2017 at 09:06

For our application we use a USB Host to communicate with a HID class device. We've constructed a way to measure the state of the device by measuring the Impedance on the USB datalines. This requires that the datalines are in a high impedance state. 

Our problem is that we cannot put the USB datalines in a high impedance state after the USB Host has been initialized.

It seems that, once the USB has been power the pull-downs can only be disabled trough a reset.

The USB de-iniitialization function does not affect the GPIO.  It seems they cannot be re-configured to something else.

Is there a way to properly disable the USB and return the original GPIO functionality to these pins?

We use STM32CubeMx Together with Atollic truestudio.

#usb-host #stm32
This topic has been closed for replies.
Best answer by waclawek.jan
Posted on October 06, 2017 at 16:39

Arsenii has found the solution.

https://community.st.com/0D50X00009XkXJZSA3

 

JW

3 replies

waclawek.jan
Super User
May 17, 2017
Posted on May 17, 2017 at 12:14

Changing AF in respective GPIO_AFRL/AFRH, and/or MODE to any other than AF in GPIO_MODER, does not help?

JW

Olov Ros�n
Associate
May 17, 2017
Posted on May 17, 2017 at 13:00

I'm using the HAL library.

I've tried to re-initialize the pins using HAL_GPIO_Init to different modes but none of them works as expected. The datalines still have the pulldowns if the usb has been initialized.  

Tried input, output_pp, output_od, analog, etc.

Something like:

GPIO_InitTypeDef GPIO_InitStruct;

GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12;

GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

The USB host driver configures the alternate function as:

GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;

Can i force remove this connection somehow?

Tried the USB_CoreReset, HAL_HCD_ResetPort.

waclawek.jan
Super User
May 17, 2017
Posted on May 17, 2017 at 13:45

I'm using the HAL library.

I don't care, neither does the chip.

I've tried to re-initialize the pins using HAL_GPIO_Init to different modes but none of them works as expected.

This is unsetling.  You might be onto something not documented properly. I faintly recall seing something similar being discussed here long ago, but can't find it.

Don't you have locked the GPIO? Read back the relevant GPIO register content.

The USB host driver configures the alternate function as:

GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;

Can i force remove this connection somehow?

As I've said, by changing the respective bits in the GPIO_AFRL/AFRH. You can do it in the debugger, no need to program.

JW

waclawek.jan
Super User
May 17, 2017
Posted on May 17, 2017 at 22:50

It's HUMM then.

ST: Please comment.

JW

Arsenii Soitu
Associate II
October 2, 2017
Posted on October 02, 2017 at 13:03

Hello! 

Was the problem fixed? I am facing the similar problem with Usb de-initialization

waclawek.jan
waclawek.janBest answer
Super User
October 6, 2017
Posted on October 06, 2017 at 16:39

Arsenii has found the solution.

https://community.st.com/0D50X00009XkXJZSA3

 

JW