Author Topic: STM32F103 not communicating with computer  (Read 4215 times)

0 Members and 1 Guest are viewing this topic.

Offline adorno

  • Contributor
  • Posts: 15
  • Country: es
STM32F103 not communicating with computer
« on: October 24, 2017, 11:06:50 am »
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.pdf

I 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 lot

Thanks for reading!
 

Offline Zucca

  • Supporter
  • ****
  • Posts: 2480
  • Country: it
  • EE meid in Itali
Re: STM32F103 not communicating with computer
« Reply #1 on: October 24, 2017, 12:05:11 pm »
Do you have a scope? What equipment you have?
Can't know what you don't love. St. Augustine
Can't love what you don't know. Zucca
 

Offline adorno

  • Contributor
  • Posts: 15
  • Country: es
Re: STM32F103 not communicating with computer
« Reply #2 on: October 24, 2017, 12:10:48 pm »
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...


 

Offline Zucca

  • Supporter
  • ****
  • Posts: 2480
  • Country: it
  • EE meid in Itali
Re: STM32F103 not communicating with computer
« Reply #3 on: October 24, 2017, 01:04:06 pm »
Nice, so first start with simple USB sanity checks:

1) 5V there
2) 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.
Can't know what you don't love. St. Augustine
Can't love what you don't know. Zucca
 

Offline cdev

  • Super Contributor
  • ***
  • Posts: 5082
  • Country: 00
Re: STM32F103 not communicating with computer
« Reply #4 on: October 24, 2017, 01:15:29 pm »
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)
"What the large print giveth, the small print taketh away."
 

Offline adorno

  • Contributor
  • Posts: 15
  • Country: es
Re: STM32F103 not communicating with computer
« Reply #5 on: October 24, 2017, 01:30:06 pm »
lsusb:
Code: [Select]
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

dmesg: it's really long so I uploaded it here
https://cl1p.net/adornoeevblog
 

Offline cdev

  • Super Contributor
  • ***
  • Posts: 5082
  • Country: 00
Re: STM32F103 not communicating with computer
« Reply #6 on: October 24, 2017, 01:47:17 pm »
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.)



« Last Edit: October 24, 2017, 01:59:33 pm by cdev »
"What the large print giveth, the small print taketh away."
 

Offline adorno

  • Contributor
  • Posts: 15
  • Country: es
Re: STM32F103 not communicating with computer
« Reply #7 on: October 24, 2017, 02:07:44 pm »
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.2V

When moving potentiometers no voltage change
 

Offline Zucca

  • Supporter
  • ****
  • Posts: 2480
  • Country: it
  • EE meid in Itali
Re: STM32F103 not communicating with computer
« Reply #8 on: October 24, 2017, 02:17:30 pm »
- Data(-): around 1.5V
- Data(+): around 0.2V

Those are VDC measurements, what about scope them?
Do you see D+(t)=-D-(t)?

Can't know what you don't love. St. Augustine
Can't love what you don't know. Zucca
 

Offline adorno

  • Contributor
  • Posts: 15
  • Country: es
Re: STM32F103 not communicating with computer
« Reply #9 on: October 24, 2017, 02:47:33 pm »
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
 

Offline cdev

  • Super Contributor
  • ***
  • Posts: 5082
  • Country: 00
Re: STM32F103 not communicating with computer
« Reply #10 on: October 24, 2017, 02:49:16 pm »
How do you know its "broken" and not just some driver problem?
"What the large print giveth, the small print taketh away."
 

Offline adorno

  • Contributor
  • Posts: 15
  • Country: es
Re: STM32F103 not communicating with computer
« Reply #11 on: October 24, 2017, 02:54:56 pm »
Not at all, both straight lines at 0.5 microseconds timebase. Data- around 4V mark and Data+ slightly below, around 3.7V
 

Offline adorno

  • Contributor
  • Posts: 15
  • Country: es
Re: STM32F103 not communicating with computer
« Reply #12 on: October 24, 2017, 02:57:47 pm »
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
 

Offline Zucca

  • Supporter
  • ****
  • Posts: 2480
  • Country: it
  • EE meid in Itali
Re: STM32F103 not communicating with computer
« Reply #13 on: October 24, 2017, 03:04:16 pm »
Not at all, both straight lines at 0.5 microseconds timebase. Data- around 4V mark and Data+ slightly below, around 3.7V

So 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.
Can't know what you don't love. St. Augustine
Can't love what you don't know. Zucca
 

Offline AndyC_772

  • Super Contributor
  • ***
  • Posts: 3547
  • Country: gb
  • Professional design engineer
    • Cawte Engineering | Reliable Electronics
Re: STM32F103 not communicating with computer
« Reply #14 on: October 24, 2017, 03:27:49 pm »
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.

Offline cdev

  • Super Contributor
  • ***
  • Posts: 5082
  • Country: 00
Re: STM32F103 not communicating with computer
« Reply #15 on: October 24, 2017, 03:33:06 pm »
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.

Not at all, both straight lines at 0.5 microseconds timebase. Data- around 4V mark and Data+ slightly below, around 3.7V

So 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.

Also, 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.

« Last Edit: October 24, 2017, 07:51:26 pm by cdev »
"What the large print giveth, the small print taketh away."
 

Offline adorno

  • Contributor
  • Posts: 15
  • Country: es
Re: STM32F103 not communicating with computer
« Reply #16 on: October 24, 2017, 06:33:40 pm »
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.
« Last Edit: October 24, 2017, 06:39:21 pm by adorno »
 

Offline SaabFAN

  • Frequent Contributor
  • **
  • Posts: 687
  • Country: de
Re: STM32F103 not communicating with computer
« Reply #17 on: October 25, 2017, 12:10:56 am »
Did you check the protection-Diodes of the USB Data-Lines?

Offline cdev

  • Super Contributor
  • ***
  • Posts: 5082
  • Country: 00
Re: STM32F103 not communicating with computer
« Reply #18 on: October 25, 2017, 01:42:54 am »
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
"What the large print giveth, the small print taketh away."
 

Offline Zucca

  • Supporter
  • ****
  • Posts: 2480
  • Country: it
  • EE meid in Itali
Re: STM32F103 not communicating with computer
« Reply #19 on: October 25, 2017, 07:54:35 am »
Did you check the protection-Diodes of the USB Data-Lines?

oh yeah...
Can't know what you don't love. St. Augustine
Can't love what you don't know. Zucca
 

Offline adorno

  • Contributor
  • Posts: 15
  • Country: es
Re: STM32F103 not communicating with computer
« Reply #20 on: October 25, 2017, 11:16:29 am »
This is the board, I don't see anything like a diode around data lines:



Maybe it's this?


 

Online Rasz

  • Super Contributor
  • ***
  • Posts: 2332
  • Country: 00
    • My random blog.
Re: STM32F103 not communicating with computer
« Reply #21 on: October 25, 2017, 03:21:09 pm »
U3 is an TVS diode array
check if its shorted with multimeter on "beep" setting
also check voltage on 1117 legs when powered on
edit:
also check continuity between end of usb cable and usb socket pins on the pcb
Who logs in to gdm? Not I, said the duck.
My fireplace is on fire, but in all the wrong places.
 

Offline adorno

  • Contributor
  • Posts: 15
  • Country: es
Re: STM32F103 not communicating with computer
« Reply #22 on: October 25, 2017, 04:23:51 pm »
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.
 

Offline gamalot

  • Frequent Contributor
  • **
  • Posts: 512
  • Country: au
  • Correct my English
Re: STM32F103 not communicating with computer
« Reply #23 on: October 25, 2017, 04:34:27 pm »
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.

https://www.onsemi.com/pub/Collateral/NUP4201MR6-D.PDF
 

Offline SaabFAN

  • Frequent Contributor
  • **
  • Posts: 687
  • Country: de
Re: STM32F103 not communicating with computer
« Reply #24 on: October 25, 2017, 04:37:55 pm »
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.

4V 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.

Offline adorno

  • Contributor
  • Posts: 15
  • Country: es
Re: STM32F103 not communicating with computer
« Reply #25 on: October 25, 2017, 04:48:21 pm »
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   :-//
 

Online Rasz

  • Super Contributor
  • ***
  • Posts: 2332
  • Country: 00
    • My random blog.
Re: STM32F103 not communicating with computer
« Reply #26 on: October 26, 2017, 06:30:26 am »
lets go further, check if FB1 common mode choke is not open, and track USB +- all the way to the microcontroller
can you make picture of the whole pcb ? both sides if its double load
Who logs in to gdm? Not I, said the duck.
My fireplace is on fire, but in all the wrong places.
 

Offline adorno

  • Contributor
  • Posts: 15
  • Country: es
Re: STM32F103 not communicating with computer
« Reply #27 on: November 05, 2017, 12:06:36 am »
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.jpg
Pins 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.




« Last Edit: November 05, 2017, 10:48:50 am by adorno »
 

Online Rasz

  • Super Contributor
  • ***
  • Posts: 2332
  • Country: 00
    • My random blog.
Re: STM32F103 not communicating with computer
« Reply #28 on: November 05, 2017, 05:26:40 am »
I checked FB1 and both sides are not shorted.

not shorted in reference to ground? or between both sides?

In the tracking red lines I mark each side of FB1.

one of your lines goes thru a cap to the ground, while both usb signals go thru fb1, it has 4 pins, and should pass signals

and the signal can be seen at the microcontroller pins.

wait, what signal? your scope cant capture so there is no way of you knowing if there ever was an attempt at handshaking
if 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
Who logs in to gdm? Not I, said the duck.
My fireplace is on fire, but in all the wrong places.
 

Offline adorno

  • Contributor
  • Posts: 15
  • Country: es
Re: STM32F103 not communicating with computer
« Reply #29 on: November 05, 2017, 10:56:44 am »
not shorted in reference to ground? or between both sides?

Between 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.

one of your lines goes thru a cap to the ground, while both usb signals go thru fb1, it has 4 pins, and should pass signals

Which cap? :scared: 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.

wait, what signal? your scope cant capture so there is no way of you knowing if there ever was an attempt at handshaking
if 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

I 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

 

Online Rasz

  • Super Contributor
  • ***
  • Posts: 2332
  • Country: 00
    • My random blog.
Re: STM32F103 not communicating with computer
« Reply #30 on: November 05, 2017, 09:37:53 pm »
one of your lines goes thru a cap to the ground, while both usb signals go thru fb1, it has 4 pins, and should pass signals

Which cap? :scared: 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.

nvm, you painted red line between cap and fb1 :)


https://youtu.be/kUXrbkRoPRY

not 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
Who logs in to gdm? Not I, said the duck.
My fireplace is on fire, but in all the wrong places.
 

Offline adorno

  • Contributor
  • Posts: 15
  • Country: es
Re: STM32F103 not communicating with computer
« Reply #31 on: November 06, 2017, 10:46:58 am »

nvm, you painted red line between cap and fb1 :)

Oh 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.

not 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

Ok, will do. What should I expect after doing it?
 

Online Rasz

  • Super Contributor
  • ***
  • Posts: 2332
  • Country: 00
    • My random blog.
Re: STM32F103 not communicating with computer
« Reply #32 on: November 06, 2017, 11:27:23 pm »
Ok, will do. What should I expect after doing it?

there 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
Who logs in to gdm? Not I, said the duck.
My fireplace is on fire, but in all the wrong places.
 

Offline adorno

  • Contributor
  • Posts: 15
  • Country: es
Re: STM32F103 not communicating with computer
« Reply #33 on: January 05, 2018, 07:00:53 pm »
I finally got time to continue this, removed U3 and the keyboard now works flawlessly :D so 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
 

Online coromonadalix

  • Super Contributor
  • ***
  • Posts: 2207
  • Country: ca
Re: STM32F103 not communicating with computer
« Reply #34 on: January 05, 2018, 08:04:16 pm »
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  ...
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf