STM32F103 not communicating with computer - Page 1
Forum section: electronics / repair

author: adorno
author_rank: Contributor
timestamp: October 24, 2017, 11:06:50 am
content: Hi there! First of all, I'm a beginner in electronics and English is not my first language, so please be patient with me. I have a problem with a midi keyboard and I want to fix it. When I plug it in the computer it's not recognized, no matter the cable or the computer I connect it to (Windows, Mac, Linux).I opened it and found the STM32F103 chip inside. Everything appears to work fine, leds light up and the buttons' programming, so that makes me think that the memory is ok and it's just a problem in the 'data output line', or in both receive/send lines from the USB.This is the datasheet of the pinout (64 pins, page 24):http://www.st.com/content/ccc/resource/technical/document/datasheet/33/d4/6f/1d/df/0b/4c/6d/CD00161566.pdf/files/CD00161566.pdf/jcr:content/translations/en.CD00161566.pdfI really don't know where to start. Reading the datasheet I thought that maybe the chip entered a permanent 'rest' state for any reason, and tried to wake it up applying 3.3V to pin14, but nothing happened. Could you guys please guide me through the troubleshooting? I'll appreciate it a lotThanks for reading!

author: Zucca
author_rank: Unknown
timestamp: October 24, 2017, 12:05:11 pm
content: Do you have a scope? What equipment you have?

author: adorno
author_rank: Contributor
timestamp: October 24, 2017, 12:10:48 pm
content: Yes, I have an old Hameg HM312-8 and one of these cheap ebay diy oscilloscope kit. And the normal equipment for a beginner, soldering station, multimeter...

author: Zucca
author_rank: Unknown
timestamp: October 24, 2017, 01:04:06 pm
content: Nice, so first start with simple USB sanity checks:1) 5V there2) D+ and D- are moving and opposite to each other...PS: Don't think I am an electronc dragon, I am just trying to help.

author: cdev
author_rank: Super Contributor
timestamp: October 24, 2017, 01:15:29 pm
content: When you plug it in in Linux, and type in "lsusb" or (sudo) dmesg, what does it say? (in the case of dmesg, at the end)

author: adorno
author_rank: Contributor
timestamp: October 24, 2017, 01:30:06 pm
content: lsusb:Code:Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hubBus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hubBus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hubBus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hubBus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hubBus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hubBus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hubBus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hubdmesg: it's really long so I uploaded it herehttps://cl1p.net/adornoeevblog

author: cdev
author_rank: Super Contributor
timestamp: October 24, 2017, 01:47:17 pm
content: Could you just paste in the very last part of your dmesg at the end, the part that changes when you plug your keyboard in.. It shouldnt be plugged in then plug it in, what occurs in your logs.. logs are usually in /var/log/*Try "ls -lat /var/log/*" after plugging it in, the most recently updated logs will be at the very top.Did you Google your keyboard's model number/name?Do you know about udev rules, drivers, etc? It can't enumerate as an STM32, it will enumerate as whatever its emulating.(The USB product and vendor IDs are embedded into the code at compile time.)

author: adorno
author_rank: Contributor
timestamp: October 24, 2017, 02:07:44 pm
content: I get 5V that then get converted to around 3V.When connected to the computer from the data cables I get:- Data(-): around 1.5V- Data(+): around 0.2VWhen moving potentiometers no voltage change

author: Zucca
author_rank: Unknown
timestamp: October 24, 2017, 02:17:30 pm
content: Quote from: adorno on October 24, 2017, 02:07:44 pmThose are VDC measurements, what about scope them?Do you see D+(t)=-D-(t)?

author: adorno
author_rank: Contributor
timestamp: October 24, 2017, 02:47:33 pm
content: I don't see anything, I plug it in and everything stays the same, it's like the keyboard uses the power from the USB but doesn't communicate at all.I have googled the keyboard model but couldn't find anything helpful, I have been using it normally since I bought it but one day it stopped working, and I have right on my desk so it didn't fall or get any physical damage.My only guess is that somehow a current/voltage spike affected something, that or it was designed to fail

author: cdev
author_rank: Super Contributor
timestamp: October 24, 2017, 02:49:16 pm
content: How do you know its "broken" and not just some driver problem?

author: adorno
author_rank: Contributor
timestamp: October 24, 2017, 02:54:56 pm
content: Not at all, both straight lines at 0.5 microseconds timebase. Data- around 4V mark and Data+ slightly below, around 3.7V

author: adorno
author_rank: Contributor
timestamp: October 24, 2017, 02:57:47 pm
content: I thought if it was a driver problem, connecting it to another computer would solve it. OS X doesn't need any driver from the manufacturer for it to work for example, and I tried it in 5 computers (x2 OS X, x2 Windows 10, x1 Linux) and nothing ever happens, not even a signal that the computer recognized anything attached to it

author: Zucca
author_rank: Unknown
timestamp: October 24, 2017, 03:04:16 pm
content: Quote from: adorno on October 24, 2017, 02:54:56 pmSo no wonder at the PC side nothing happens...Can you unplug the PC and feed the 5V USB to the keyboard with a lab power supply? When you plug the 5V you should see some activities at the D+ and D- lines. If not it´s a HW issue not SW.

author: AndyC_772
author_rank: Super Contributor
timestamp: October 24, 2017, 03:27:49 pm
content: Start by probing a known-good USB device when you plug that in. Make sure you can set up your scope correctly to see activity on the D+ and D- lines, and then when you're sure you can see something that looks correct, try the faulty device.

author: cdev
author_rank: Super Contributor
timestamp: October 24, 2017, 03:33:06 pm
content: Often a USB device is not getting enough voltage to work properly when plugged into a computer (this is much more common with laptops) but then using an externally powered USB hub makes the device work.Quote from: zucca on October 24, 2017, 03:04:16 pmAlso, maybe its me but the site you uploaded your dmesg log to says its empty.You shouldn't upload the entire thing, just what happens when you unplug and replug in the device- it should be at the end.Does the device enumerate itself- i.e. show up in any of the "device trees" shown on any of the three OS's you have plugged it into?You can type "lsusb" on linux both before and after plugging it in, whatever changes.. Also, do any new entries show up in the /dev/ directory when you plug it in?Also, there is a linux program you can install called usbview which can give you some additional information..You could also install wireshark to see what is being sent back and forth from its perspective.

author: adorno
author_rank: Contributor
timestamp: October 24, 2017, 06:33:40 pm
content: Ok, here I bring what the oscilloscope is displaying:Explanation: first I have an USB mouse connected, the normal waves used for data transfer are seen. Then I disconnect the mouse, two flat lines are displayed, then there's one flash of me trying to connect the midi keyboard, and then when the lines distance from each other is the moment I plug the keyboard in. After a few times 'resetting' like in the gif, it stops.BTW: I adjusted the Y axis of the scope so both probes are right on the X axis.What do you guys think? It seems like at least it's trying to do something but there's a failure in that process and restarts, as I said earlier, the PC does not react at all.

author: SaabFAN
author_rank: Frequent Contributor
timestamp: October 25, 2017, 12:10:56 am
content: Did you check the protection-Diodes of the USB Data-Lines?

author: cdev
author_rank: Super Contributor
timestamp: October 25, 2017, 01:42:54 am
content: Can you extract any USB product ID or vendor id at all?This is a useful list of them...http://www.linux-usb.org/usb.ids

author: Zucca
author_rank: Unknown
timestamp: October 25, 2017, 07:54:35 am
content: Quote from: SaabFAN on October 25, 2017, 12:10:56 amoh yeah...

author: adorno
author_rank: Contributor
timestamp: October 25, 2017, 11:16:29 am
content: This is the board, I don't see anything like a diode around data lines:Maybe it's this?

author: Rasz
author_rank: Super Contributor
timestamp: October 25, 2017, 03:21:09 pm
content: U3 is an TVS diode arraycheck if its shorted with multimeter on "beep" settingalso check voltage on 1117 legs when powered onedit:also check continuity between end of usb cable and usb socket pins on the pcb

author: adorno
author_rank: Contributor
timestamp: October 25, 2017, 04:23:51 pm
content: Is there any way to check which diode array is it? Pin 2 is ground, no shorts between any pins.Voltage in 1117 is 4V, 2.5V and Ground. I'm getting 4V in miniUsb V+ pin.There's continuity between usb cable and socket pins.

author: gamalot
author_rank: Super Contributor
timestamp: October 25, 2017, 04:34:27 pm
content: Quote from: adorno on October 25, 2017, 04:23:51 pmhttps://www.onsemi.com/pub/Collateral/NUP4201MR6-D.PDF

author: SaabFAN
author_rank: Frequent Contributor
timestamp: October 25, 2017, 04:37:55 pm
content: Quote from: adorno on October 25, 2017, 04:23:51 pm4V is too low. As is 2.5V. The markings on the 1117 state it is the 3.3V model.Your STM32 is getting not enough voltage to work properly.This is either because your computer cannot deliver the power necessary, the connector is damaged / has corroded contacts, or the cable you are using is bad.I'd suggest trying a different cable and cleaning the USB-Connector if you haven't done that already.

author: adorno
author_rank: Contributor
timestamp: October 25, 2017, 04:48:21 pm
content: My multimeter must be broken, if it was a problem from one computer it wouldn't explain why it doesn't work with others.I've checked with the scope and it displays the expected 5V and 3.3V

author: Rasz
author_rank: Super Contributor
timestamp: October 26, 2017, 06:30:26 am
content: lets go further, check if FB1 common mode choke is not open, and track USB +- all the way to the microcontrollercan you make picture of the whole pcb ? both sides if its double load

author: adorno
author_rank: Contributor
timestamp: November 05, 2017, 12:06:36 am
content: I checked FB1 and both sides are not shorted. In the tracking red lines I mark each side of FB1.Both data lines go where they should according to the stm datasheet:http://www.olliw.eu/uploads/stm32f103rb-pinlayout-wp01.jpgPins 44 and 45 (CAN_TX and CAN RX), and the signal can be seen at the microcontroller pins.Here are two photos of the board, the rest that is not seen is where all the buttons are placed, I took a pic of where the 'brain' is.

author: Rasz
author_rank: Super Contributor
timestamp: November 05, 2017, 05:26:40 am
content: Quote from: adorno on November 05, 2017, 12:06:36 amnot shorted in reference to ground? or between both sides?Quote from: adorno on November 05, 2017, 12:06:36 amone of your lines goes thru a cap to the ground, while both usb signals go thru fb1, it has 4 pins, and should pass signalsQuote from: adorno on November 05, 2017, 12:06:36 amwait, what signal? your scope cant capture so there is no way of you knowing if there ever was an attempt at handshakingif you cant get a scope able to sample at ~2MHz and capture on trigger and your desperate enough you could desolder U3, C18/19, FB1 and jumper over it.I hope you checked with different usb cable already

author: adorno
author_rank: Contributor
timestamp: November 05, 2017, 10:56:44 am
content: Quote from: Rasz on November 05, 2017, 05:26:40 amBetween both sides, FB1 should not have any ground connection. Both data lines goes through the same FB1, but each has its different path, they do not touch each other.Quote from: Rasz on November 05, 2017, 05:26:40 amWhich cap?I see they have exactly the same path, one goes trough left side FB1, a filter capacitor (that passes high freq signals to ground), and through 220 resistor. The other signal is the same but going through the right side of FB1.Quote from: Rasz on November 05, 2017, 05:26:40 amI tried 4 different cables in 4 different computers. I showed what I see on the scope before, and this is what I see on the digital 'hi chinese quality' oscilloscope when I connect it:https://youtu.be/kUXrbkRoPRY

author: Rasz
author_rank: Super Contributor
timestamp: November 05, 2017, 09:37:53 pm
content: Quote from: adorno on November 05, 2017, 10:56:44 amnvm, you painted red line between cap and fb1Quote from: adorno on November 05, 2017, 10:56:44 amnot very differential, D- should be pulled high to signal low speed, but you have both sides pulled high(one of them so hard your "scope" cant even see it going down), wouldnt hurt to remove U3 and recheck

author: adorno
author_rank: Contributor
timestamp: November 06, 2017, 10:46:58 am
content: Quote from: Rasz on November 05, 2017, 09:37:53 pmOh sorry, I think it's a weird effect due to the macro lense. fb1 has 4 pins, right below 'F' (FB1 written on the board) there are 2, and below '1' the other 2, so both data lines pass through the same ferrite bead.Quote from: Rasz on November 05, 2017, 09:37:53 pmOk, will do. What should I expect after doing it?

author: Rasz
author_rank: Super Contributor
timestamp: November 06, 2017, 11:27:23 pm
content: Quote from: adorno on November 06, 2017, 10:46:58 amthere is a slight possibility diode array is clamping one of the lines high, or microcontroller itself is doing it, or transitions are too quick to show up on the 1MHz scope toy. You could try triggering on ~2V with analog scope and check it it catches anything at all one the faulty line.btw low speed usb can be logged/captured/debugged using $4 "CY7C68013A-56 EZ-USB FX2LP USB2.0 Develop Board Module"https://sigrok.org/wiki/Lcsoft_Mini_Board

author: adorno
author_rank: Contributor
timestamp: January 05, 2018, 07:00:53 pm
content: I finally got time to continue this, removed U3 and the keyboard now works flawlesslyso I'm going to order another diode array and replace it. Would it be bad to use the keyboard without U3 in the meantime?Thanks a lot for all who helped, specially you Rasz

author: coromonadalix
author_rank: Super Contributor
timestamp: January 05, 2018, 08:04:16 pm
content: the tvs is a protection against spikes / transient voltages, serve as voltage limitting too, just dont connect the usb cable when powered ... you may have ground voltages potential / differences when unconnected ...