cancel
Showing results for 
Search instead for 
Did you mean: 

USB Toggling States between Enumerate and Idle

Rogers.Gary
Senior II

I set up USB host in Cube MX. The STM32L476 hardware to the USB is connected the same as I have successfully used previously in an F4 processor. I am using pin PA8 to drive the power switch (STMPS2141STR)

Under "Connectivity", the mode is "Host Only". VBUS_Sensing is activated (although this did not seem to matter) The SOE and SOF boxes are not checked. Under "Middleware", USB_HOST set up for BSP "Drive VBUS_FS" is GPIO_Output, and I selected the PA8 pin "Found Solutions"

I then generated the code, and among other additions of code, it placed a call in main while(1) loop: MX_USB_HOST_Process(); Right after that, I placed a call: "HAL_Delay(1000)" so the output of a printf could be seen.

What is happening (or not): software does not appear to detect the connection when I plug in a USB stick. In the module "usbh_core.c" there is a function "USBH_Process(USBH_HandleTypeDef *phost)". Just before the switch statement, I placed a printf:

printf("state = %i\n", phost->gState);

I started with no stick plugged into the board, and at the fourth print of "state = 5", I plugged it in. The current draw on the power supply went up, so it did appear the USB was detected in hardware as the supply switched on. Here is the print out:

state = 0

state = 2

state = 5

state = 5

state = 5

state = 5 *At this point I plugged in the USB stick*

state = 5

state = 5

state = 3

state = 0

state = 3

state = 0

...and keeps doing this toggling

According to the enum for phost->gState, it toggles: HOST_IDLE, HOST_DEV_ATTACHED, HOST_ENUMERATION (6x), HOST_DEV_DISCONNECTED,HOST_IDLE,...

Also - why does it say the device was attached before it was plugged in? Then, after plugging it in, it goes to disconnect, then idle repeatedly between those states?

Since no examples are available anywhere, it makes it difficult to figure out what could be going on. Also, I am using a USB stick that does work on the previous F4 implementation.

11 REPLIES 11
WBOUG
Senior

Hello

I promised you to send you the project you wanted and that's the case

You find in piece to join the functional USB poject.

Best Regards,

Wael

Rogers.Gary
Senior II

Hello Wael:

I will check it over, appreciated. I re-posted my tech support case last night. I followed the example from the STM32L476VG processor, the same one I am using, that's used on the EVAL board. I also verified my hardware connectivity is the same, as the EVAL board. Initialization and calls are the same. Yet the detection of the device (tried several) does not occur (state remains at idle). I will try your example and see what happens.

Thanks again, will be in touch