cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F2 USB-FS-HID not enumerate to Windows

tomaskrueger
Associate II
Posted on May 24, 2014 at 21:27

Hi All,

Using the USB-FS HID device example , STM32_USB-Host-Device_Lib_V2.1.0.

Using the FS/Internal PHY with DM DP and VBUS connected to USB Cable.

Using a basic custom board with just a STM32F205, power, JTAG, serial.

Using a 25Mhz crystal for the proc to run at 120Mhz.

I am using the above HID example code with just the LCD removed and debug to serial.

When i plug it into the PC, Windows popsup an error message ''USB device not recoqnized''. Windows devicemanager shows an ''unknown device'' with PID/VID ''unknown''.

The internal 1.5K Pullup on D+  initiates the enumeration by the Host(PC),

but it seems no DeviceDescriptor is transmitted via Endpoint 0, so the Host does not know who ''said hello''.

The debug output looks like this:

>>>SYS_RESET<<<

SYSCLOCK(PLL):120000000, HCLK(CPU):120000000, PCLK1(APB1):30000000, PCLK2(APB2):60000000

Init

Connected

Reset

Reset

Reset

Reset

Suspended

USB needs a 48Mhz clock. Is there a way to verify the 48Mhz clock ??

Also in the USB init code i saw the following line:

   RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);  ?????

#stm32f2-usb
5 REPLIES 5
Posted on May 25, 2014 at 00:22

USB needs a 48Mhz clock. Is there a way to verify the 48Mhz clock ??

You can read the PLL divider used, you can measure the PLL, you can observe the clock via the SDIO clock. In other examples I've added a computed version of SystemCoreClock, and PLL Q Clock From system_stm32f4xx.c (would work for F2 as well)

/** @addtogroup STM32F4xx_System_Private_Variables
* @{
*/
#if defined (PLL_SOURCE_HSI)
uint32_t SystemCoreClock = ((HSI_VALUE / PLL_M) * PLL_N) / PLL_P;
uint32_t USBSDIORNGClock = ((HSI_VALUE / PLL_M) * PLL_N) / PLL_Q;
#else
uint32_t SystemCoreClock = ((HSE_VALUE / PLL_M) * PLL_N) / PLL_P;
uint32_t USBSDIORNGClock = ((HSE_VALUE / PLL_M) * PLL_N) / PLL_Q;
#endif

Suspect the MCOx pins are in the SYSCFG domain
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
tomaskrueger
Associate II
Posted on May 26, 2014 at 21:30

ok, i digged a bit into the code.

 In USB_OTG_BSP_Init(...) in usb_bsp.c, the VBUS pin PA9 is configured as a GPIO input instead of alternate function. ???interesting??? 

  /* Configure  VBUS Pin */

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;

  GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;

  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;

  GPIO_Init(GPIOA, &GPIO_InitStructure);  

i wonder why that is. it works though and shows connect/disconnect Events.

The

'' RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);'' seems to be related to the EXTI interrupt for powerdown-wakeup. ??

 

After all, i presume that the clock is correct as the debug output shows ''Reset-events''.

I indeed switched several different boards to verify.

We are using a 25Mhz crystal, same as the F2 eval board for which the example was made.

(We are not using the powerdown features with the EXTI interrupts)

Scope attached to D+ shows a ''high-level'' on D+ to start enumeration.

Host seems to send 4 times ''Reset-command'' to our device.

The 4 bursts are seen on the Scope.

After that, silence which results in ''suspend''.

Windows says: ''USB error , code 43''. (Device malfunction)

As to the F2 programmers manual the USB enumeration corse of action is as follows:

1-Device signals ''attach'' to Host via PullUp on D+.  (Session request)

2-Host sends RESET command to device.  (which indeed happened 4 times here)

   Device enters the ''default state'' after Reset-command.

3- Host sends the ''Set Address'' command to device. (Session Address)

    Device enters the ''addressed state''

Now Device is ready to accept requests on its Endpoints.

If no activity on the USB-bus for 3msecs, Device enters the ''suspend-state''.

A ''Resume'' command can reactivate the Device.

So here we are with just ''Reset'' getting.

Any clues out there?

chen
Associate II
Posted on May 27, 2014 at 12:53

Hi

''After all, i presume that the clock is correct as the debug output shows ''Reset-events''.''

Not necessarily!

''When i plug it into the PC, Windows popsup an error message ''USB device not recoqnized''. Windows devicemanager shows an ''unknown device'' with PID/VID ''unknown''.''

This is a classic symptom of the USB peripheral device being clocked incorrectly. The USB transfers are going but the bit rate is wrong so the PC cannot understand what is being sent.

tomaskrueger
Associate II
Posted on May 27, 2014 at 21:04

>>>

PROBLEM SOLVED

<<<

Thank you all for your inputs.

Guess what?

I didnt check the most obvious reason.

DP and DM where swapped.

I looked at Wikipedia USB Plug Picture and it says D+ on the right side. Well that was wrong its the left.

i am now happily communicating (smile).

This post gave me the hint:

https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2Fcortex_mx_stm32%2FEtching%20Own%20Boards%20-%20USB%20Problem&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=668

tomaskrueger
Associate II
Posted on May 27, 2014 at 21:52

Just a little drawback:

Its only working with >

//#define VBUS_SENSING_ENABLED  in usb_conf.h.

Thus VBUS sensing disdabled.

When i enable VBUS sensing i get nice ''connect/Disconnect'' events, but D+ will not go high and no reaction from Windows side.

This Windows tool MS USBView, distributed on FTDI site, is quite helpfull.

http://www.ftdichip.com/Support/Utilities/usbview.zip