cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L100RB Faulty USB SIE???

kjwhitcombe
Associate II
Posted on October 04, 2014 at 09:18

I've been spending quite some time trying to get the VCP from STSW-STM32121 to work on my STM32L100RB project to no avail and this is what I have found.

DP is being pulled up by the 1.5kohm resistor but never does anything (I see no activity)

DM goes high (both lines are now high, this is completely illegal for USB and should never happen.) when the USB module is initiated, the USB_ISTR register contains 0x2000 (ERR bit set) on the first LP interrupt, it then contains 0x0100 (ESOF) on the next two interrupts followed by 0x0900 (SUSPend + ESOF), after which it goes into resume mode (as per the code in  STSW-STM32121, USB_CNTR |=  0x0010) and DM is then driven low (for 11 USB interrupts) before coming out of resume and the whole cycle starts again.

Weirder still is as DP is pulled high by 1.5k resistor = FS USB Device and so Resume mode (K state) should be DP low, DM high, not the other way around as I am seeing here.

Reading RXDP,RXDM status in USB_FNR reg and passing it on to GPIO somewhere else to be probed shows there is no issue there (they cloned DP,DM exactly) so only issue is in the driving of these pins from the USB peripheral block.

All of the above is the behavior of the USB not connected to a host, when connected to the host the host ignores it and so still behaves the same way.

I assume my particular chip isn't faulty unless the batch I have is as all 3 of them are doing this.

Such behavior from the USB has led me to believe that the actual design of it is faulty and it will never work as the behavior it is exhibiting is out of software control?

Any words of advice would be much appreciated

#stm32l100-usb
5 REPLIES 5
kjwhitcombe
Associate II
Posted on October 05, 2014 at 21:38

Has anyone or does anyone even know of anyone succeeding in getting USB to work on the STM32L100Rxxx????

Simply knowing that would help heaps.

Thanks.
tsuneo
Senior
Posted on October 07, 2014 at 16:47

I don’t touch STM32L100 yet, but I believe this chip has the same USB engine as STM32L15x, because these chips share the same Reference Manual.

As of STM32L15x, here is a discussion of ''not connect'' type.

https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/USB%20CDC%20on%20STM32L%20device%20%20unable%20to%20connect%20to%20host

Tsuneo

kjwhitcombe
Associate II
Posted on October 09, 2014 at 10:47

Thank you kindly for your reply.

Unfortunately I had tried the changes mentioned in that thread, and a few others before posting here. I was without success, and it may pay to mention that those changes made no change in the behaviour of the device.

tsuneo
Senior
Posted on October 10, 2014 at 08:56

Hi, STM32L100 Discovery board comes to me, at last.

I ported the VCP example of the USB library on this board.

Successfully enumerated, and loopback test, under tied USART TX-RX, runs as expected.

As there were so many modifications, I attached VCP files to this post.

Here is a brief memo for porting on Keil MDK-ARM v4

A) Hardware

a) USB connector

A standard-B USB connector is added for the target STM32L100 chip.

STM32L100 USB

DISCOVERY receptacle

PA11 --------------- D-

PA12 --------------- D+

GND --------------- GND

As a self-powered device, the voltage of USB VBUS pin should be monitored by the stack over a spare port, but this function is not implemented yet.

b) External clock from ST-Link/V2 (8MHz)

As the default of STM32L100 Disco board, the on-board ST-Link/V2 supplies 8MHz clock to the PH0(OSC_IN) pin of the target STM32L100, (thought the manual of this board tells a different default combination of the solder jumpers)

B) Poring of USB library

The VCP example of STM32_USB-FS-Device_Lib_V4.0.0 (STSW-STM32121) is ported to this board.

- Start from ''STM32L100 Value line discovery firmware package'' stsw-stm32131_v100,

http://www.st.com/web/catalog/tools/FM147/CL1794/SC961/SS1743/LN1734/PF259264

- The entire STM32_USB-FS-Device_Driver folder on STM32_USB-FS-Device_Lib_V4.0.0 is dragged in under Libraries folder in STM32L100C-Discovery_FW_V1.0.0

- The Demonstration folder is duplicated/renamed to VCP folder under STM32L100C-Discovery_FW_V1.0.0\Projects\ folder

- The source files of Virtual_COM_Port example,

\STM32_USB-FS-Device_Lib_V4.0.0\Projects\Virtual_COM_Port\src and \inc

are dragged into the VCP folder.

A couple of files are replaced, or merged.

As the modifications were so many, I don’t write them down here.

To know the details of the modifications, please apply a ''diff'' utility, like WinMerge, to the attached files with the original.

- On the copied IDE project,

The preprocessor macros are modified as follows,

USE_STDPERIPH_DRIVER,STM32L1XX_MDP,STM32L1XX_MD_PLUS,USE_STM32L152D_EVAL

These files are additionally registered to the IDE project,

From VCP folder,

main.c, stm32l1xx_it.c, system_stm32L1xx.c, hw_config.c,

usb_desc.c, usb_endp.c, usb_istr.c, usb_prop.c, usb_pwr.c,

From USB-FS-Device_Driver

usb_core.c, usb_init.c, usb_int.c, usb_mem.c, usb_regs.c, usb_sil.c

Note for clock source,

In this implementation, the external clock from ST-Link/V2 is applied.

For external crystal,

- Replace RCC_HSE_Bypass to RCC_HSE_ON

- Tune RCC_CFGR_PLLMUL12 macro,

so that the product of (crystal frequency) x RCC_CFGR_PLLMULxx gives 96 MHz

For USB operation, valid clock source, like a crystal or external OSC, is required.

system_stm32l1xx.c
static void SetSysClock(void)
{
RCC_HSEConfig( RCC_HSE_Bypass ); // <-- RCC_HSE_ON
..
RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLSRC_HSE | RCC_CFGR_PLLMUL12 | RCC_CFGR_PLLDIV3);

Enjoy ;)

Tsuneo

________________

Attachments :

L100_Disco_VCP.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0gY&d=%2Fa%2F0X0000000bcR%2FxIslM7DjDyXs5.aXpOkrCXclUuZH5VYsho.AB2lPibI&asPdf=false
kjwhitcombe
Associate II
Posted on October 13, 2014 at 08:50

Thank you very much for your reply Tsuneo.

I was using the Coide for porting in STSW-STM32121, seeing as Keil worked for you I reluctantly gave it a chance (Have had experience with 8051 on Keil that I so wish I could forget as it still gives me nightmares), spent uncountable number of  hours trying to do as you have instructed only to find it didn't work out for me (processor acts like it is stuck in reset or erased). Then decided to try make a skeleton program light an LED - and after 2 hours of trying to just do that no luck there either. Going to have to throw in the towel I think. It is due in 2 days - This one is going to tax my grades severely.