0
\$\begingroup\$

I have a strange problem with USB CDC mode in STM32F103. I have designed PCB with STM32F103 microcontroller and an accelerometer which streams data through USB to PC. I have used STM32CubeMX wizard. It powers itself from USB like this well know blue pill device.

The main problem is that device works perfectly when I plug it for the first time to my PC (it doesn't matter if it's Windows, Ubuntu or Raspberry Pi) but when I disconnect it physically and then when I try to plug it once again it doesn't connect. In general second connection sometimes works sometimes doesn't. Of course, when I reset PC the first connection works again.

Have anyone had a similar problem? I think that posting a solution will be beneficient to many other developers :)

UPDATE: I noticed that if I unplug my device and plug it right away it causes "failed to set dtr/rts" but if I wait several seconds and plug it no errors occur. Below I attached dmesg logs.

[14388.242015] usb 2-1.2.4: new full-speed USB device number 7 using ehci-pci
[14388.352862] usb 2-1.2.4: New USB device found, idVendor=0483, idProduct=5740
[14388.352867] usb 2-1.2.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[14388.352870] usb 2-1.2.4: Product: STM32 Virtual ComPort
[14388.352873] usb 2-1.2.4: Manufacturer: STMicroelectronics
[14388.352876] usb 2-1.2.4: SerialNumber: 00000000001A
[14388.427460] cdc_acm 2-1.2.4:1.0: ttyACM0: USB ACM device
[14388.427755] usbcore: registered new interface driver cdc_acm
[14388.427756] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
[14399.285342] usb 2-1.2.4: USB disconnect, device number 7
[14399.287602] cdc_acm 2-1.2.4:1.0: failed to set dtr/rts
[14400.786034] usb 2-1.2.4: new full-speed USB device number 8 using ehci-pci
[14400.896587] usb 2-1.2.4: New USB device found, idVendor=0483, idProduct=5740
[14400.896592] usb 2-1.2.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[14400.896596] usb 2-1.2.4: Product: STM32 Virtual ComPort
[14400.896599] usb 2-1.2.4: Manufacturer: STMicroelectronics
[14400.896601] usb 2-1.2.4: SerialNumber: 00000000001A
[14400.897005] cdc_acm 2-1.2.4:1.0: ttyACM0: USB ACM device
[14424.885653] usb 2-1.2.4: USB disconnect, device number 8
[14446.610270] usb 2-1.2.4: new full-speed USB device number 9 using ehci-pci
[14446.720618] usb 2-1.2.4: New USB device found, idVendor=0483, idProduct=5740
[14446.720622] usb 2-1.2.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[14446.720625] usb 2-1.2.4: Product: STM32 Virtual ComPort
[14446.720627] usb 2-1.2.4: Manufacturer: STMicroelectronics
[14446.720629] usb 2-1.2.4: SerialNumber: 00000000001A
[14446.721105] cdc_acm 2-1.2.4:1.0: ttyACM0: USB ACM device
\$\endgroup\$

closed as too broad by Chris Stratton, RoyC, Dmitry Grigoryev, laptop2d, awjlogan Oct 16 '18 at 7:46

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    \$\begingroup\$ I am afraid you need to post your schematics, especially the power path and hardware reset path. It sounds like you don't have proper reset to your MCU. \$\endgroup\$ – Ale..chenski Oct 13 '18 at 23:10
1
\$\begingroup\$

It is common problem and you need to have an additional pin to force the enumeration - best after the all initialization code. (the third pin of the pnp transistor should be connected to the Vdd

enter image description here

\$\endgroup\$
  • \$\begingroup\$ Thanks for the replay! I really appreciated your answer but the problem must be somewhere else. Please check this ST Discovery board scheme. It doesn't have such transistor for disconnecting pull-up resistor and it still works with no such problems. \$\endgroup\$ – Dariusz Oct 15 '18 at 13:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.