cancel
Showing results for 
Search instead for 
Did you mean: 

Porting USB example project to specific MCU

tpphysik
Associate II
Posted on July 28, 2014 at 16:12

Hello,

I'd like to use an USB example project on a different (but very similar) microcontroller on a custom board.

The example project: STM32 USB FS Device Library V4.0.0 --> VirtualComport_Loopback project --> STM3210B-EVAL board

The new targetMCU: STM32F102xB

Both are STM32F10x so there shouldn't be a big difference about the usb peripheral, maybe only the pinout I think?

What I did so far: modified project target MCU (STM32F10X_MD), defined desired clock frequency(there is an external 4MHz crystal, system clock is set to 24MHz, and USB gets 48MHz independently), cleaned the eval board specific LED and button functions because my board is different, in platform_config.h I set USB_DISCONNECT, USB_DISCONNECT_PIN, and RCC_APB2Periph_GPIO_DISCONNECT defines to match the port/pin of USB_DP pin of the MCU, I aslo have external 1.5k pullup resistor on USB_DP so I've uncommented #define USB_USE_EXTERNAL_PULLUP.

So far it doesn't work, when I plug in the usb nothing happens on Windows (no new device). Also when I program the chip, the debugger disconnects after some time (2 seconds) and I can't connect the chip again, I can only reflash using the ST-Link utility.

So what else do I have to change to get it working?

Thank you for your help.
3 REPLIES 3
tpphysik
Associate II
Posted on July 30, 2014 at 16:01

What software problem can cause that the debugger disconnects shorty after the code begins to run? Then I can reflash the MCU only with the ST-Link -> Connect Under Reset option.

Is it caused by reconfiguring the JTAG pins (input/output)? Or can it be caused by sleep or USB suspend state?
Posted on July 30, 2014 at 16:19

Yes, the ST-LINK would be particularly prone to dumping the connection if the CPU is put in a low power mode (WFI, SLEEP, STOP, etc)

You might be able to alter this via a DBGMCU register controlling the behaviour when the debugger is attached.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
tpphysik
Associate II
Posted on July 30, 2014 at 22:08

Thank you, yes that was the case. I've set DBGMCU and now the debugger doesn't disconnect.

I still have the original problem that the ported code doesn't work on this microcontroller. What could I have forgot to change? When I plug in the USB cable, nothing happens.