cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103, HAL, USB CDC: hangup after reconnect

nitr0
Associate II
Posted on January 11, 2016 at 23:54

Hi.

I'm trying to make CDC console on STM32 device. But I've noticed some troubles:

1. When I re-connect USB cable to device, device just hangs. It seems like bug is in USB library - even blank project, that is generated by fresh CubeMX, hangs. This is most annoying trouble.

2. When I press reset, host PC (Linux) doesn't receive any re-initialization event, so connection becomes lost. Dev board have pull-up resistor directly to power line, so I can't emulate device reconnect. Can this be fixed in some way?

3. Startup (mostly - clocks initialization) takes enough long (~0.5-1 sec). For battery-backed device this isn't a trouble, but if I connect demo board directly to USB, it's often detected as unknown device. Can I do something with this?

MCU - STM32F103C8T6

#usb #cdc #cdc #stm32cube #stm32f1
5 REPLIES 5
nitr0
Associate II
Posted on January 15, 2016 at 09:52

Slow startup was caused by LSE clock (it seems like something wrong with resonator/capacitors). Somewhy it also affects USB bus (???) - board periodically wasn't detected by PC (even when it works from st-link power - so initialization timeout doesn't hurt USB).

Posted on January 15, 2016 at 17:06

I'd check the fail through sequences on the clocks and PLL. The USB peripheral requires the PLL is running, and 48 MHz is output via the Q tap.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
nitr0
Associate II
Posted on January 15, 2016 at 18:16

Clocks are initialized correctly (I didn't touched them as cubemx sets them). This issue related to LSE onboard generator. With same code board may work OK (just with startup delay), and after a while - may not be detected at all via USB. I can't understand how LSE can involve USB.

Altough, other issues (hangup on USB reconnect and re-initialization lacking on reset) aren't solved (I didn't look on it deeply).

Posted on January 15, 2016 at 18:47

I didn't touched them as cubemx sets them

Ok, but doesn't it give up and abort when things don't work properly? The LSE should have no material impact on the chip and the functioning of the USB peripheral

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Walid FTITI_O
Senior II
Posted on February 10, 2016 at 18:42

Hi denisenko,

Take a look to the following discussions , I thinkthat will give you a solution for each point ou have asked:

1. ->

https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFolder=https%3a//my.st.com/public/STe2ecommunities/mcu/Lists/STM32Java/CubeF4.10%20%2b%20FreeRTOS%20%2b%20USB%20CDC%20%2b%20F427VI%20%20%3d%20Hardfault&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000F9A0E3A95BA69146A...

2. -> [DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/STM32F4%20USB%20CDC%20Transfer%20Problems&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=23]discussion2

3. -> [DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Java/Bug%20report%20USB%20CDC%20Template%20and%20CubeMX%20code%20generation&currentviews=12]discussion3

-Hannibal-