cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L USB CDC VirtualCom example : device not recognized

nigel2
Associate II
Posted on January 21, 2015 at 10:34

Hi

I'm a relative newbie in using ST or ARM devices, and I'm attempting to get a USB CDC device working using the VirtualCom example code, using an STM32L152 in a custom pcb.

I'm using the Kickstart edition of IAR embedded workbench (is there a problem using this?)

The main problem I'm having at the moment is that when I build my code and download it to the mcu, then plug the USB into my PC (64 bit Windows 7 Pro), I get a message on the PC ''USB device not recognized'', and the device appears in Device Manager  with a yellow triangle named ''Unknown Device''.

If I look in Device Manager at the ''Unknown Device'''s properties : they start as follows:

Device Description : Unknown Device

Hardware IDs : USB\UNKNOWN

On our pcb, we've got an 8 MHz crystal clock on the HSE

What I'm intending to do is to get the PLL producing 48MHz for the USB... and the fastest possible SYSCLK.

HSE = 8 MHz

PLLMUL = 6

so 

PLLVCO = 6*8 = 48 MHz

PLLDIV = 2

so

SYSCLK = 24 MHz

AHB, APB1, & APB2 prescalers are all set to 1

I've used RCC_GetClocksFreq() to get the configured clocks' frequencies and that tells me that the code thinks SYSCLK, HCLK, PCLK1 & PCLK2 are all 24 MHz. I therefore assume that USBCLK is correctly set to 48 MHz.

I've tried setting MCOPRE to 1 and MCOSEL to output SYSCLK, and can measure 24.000 MHz on the MCO pin. so I know that seems to be working.

Does anyone have any ideas what could be wrong please ?

#cdc #usb
3 REPLIES 3
sdim
Associate III
Posted on January 22, 2015 at 20:40

Try to disable VBUS sensing.

  hpcd_USB_OTG_HS.Init.vbus_sensing_enable = DISABLE;

nigel2
Associate II
Posted on January 23, 2015 at 13:00

Unfortunately, I can find nothing about VBUS in the reference manual (RM0038) for the STM32L152xx device we're using.

(the part number on the chip is STM32L152RDT6)

Our pcb does not have the vbus line connected (it's self powered)

Searching the source coed (for the VirtualCom example and include files) there's no reference to vbus either, so if I try to add

hpcd_USB_OTG_HS.Init.vbus_sensing_enable = DISABLE; 

the code won't compile.

nigel2
Associate II
Posted on January 28, 2015 at 18:22

Problem solved.

There were 2 issues. One was on our own custom PCB (an unused chip was dragging the USB line down), the other was in the Clock Tree.

Looking at the clock tree in document RM0038, which can be found

http://www.st.com/web/en/resource/technical/document/reference_manual/CD00240193.pdf

, on page 130, it was not clear that the PLL VCO is divided by 2 before its sent to the USB device.

I also had to change the values of idVendor and idProduct in usb_dev_desc.c to match those in the inf file (driver), so I changed 

    0xFFFF,                                     // idVendor

    0x0048,                                     // idProduct

to

    0x0483,                                     // idVendor

    0x05740,                                     // idProduct

Now I've put the clock tree code back as it was in the VirtualCom example, Windows sees the USB driver and I can move forward with my project.