cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot de-initialize USB Host pull down on STM32F407

Olov Ros�n
Associate II
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
1 ACCEPTED SOLUTION

Accepted Solutions
Posted on October 06, 2017 at 16:39

Arsenii has found the solution.

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

 

JW

View solution in original post

7 REPLIES 7
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

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.

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

Posted on May 17, 2017 at 15:15

Thanks for the clarification!

So I've checked the registers 

GPIO_AFRL/AFRH and 

GPIO_MODER during the USB host initialization/de-initialization with a debugger and they do get set and reverted back to the same value as before the initialization. 

The re-configuration after also set the registers correctly.... but the pull down:s are still there. 

Any ideas?
Posted on May 17, 2017 at 22:50

It's HUMM then.

ST: Please comment.

JW

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

Hello! 

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

Posted on October 06, 2017 at 16:39

Arsenii has found the solution.

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

 

JW