felis / USB_Host_Shield_2.0

Revision 2.0 of USB Host Library for Arduino.
https://chome.nerpa.tech
1.8k stars 779 forks source link

USB.Init() function looping forever #402

Open ghost opened 6 years ago

ghost commented 6 years ago

Hi all,

I'm using a Teensy 3.2 along with the USB Host Shield Mini. I installed both the USB_Host_Shield_2.0 library and spi4teensy3 library. I tried running the XBOXUSB example, as I have a wired Xbox 360 controller plugged in the Shield.

This example, aswell as the USB_desc example both get stuck on the USB.Init() line ( https://github.com/felis/USB_Host_Shield_2.0/blob/master/examples/Xbox/XBOXUSB/XBOXUSB.ino#L23 ) I have also set ENABLE_UHS_DEBUGGING in settings.h to 1 ( https://github.com/felis/USB_Host_Shield_2.0/blob/master/settings.h#L42 ) and uncommented EXTRADEBUG and PRINTREPORT in XBOXUSB.cpp ( https://github.com/felis/USB_Host_Shield_2.0/blob/master/XBOXUSB.cpp#L20 ) although I'm not sure where this debugging information would be shown? I don't see it show up in the Serial Monitor in the Arduino IDE.

Any help towards resolving this issue would be greatly appreciated. Thanks in advance!

xxxajk commented 6 years ago

https://github.com/felis/USB_Host_Shield_2.0/blob/master/settings.h#L42

ghost commented 6 years ago

Thanks for your reply @xxxajk! Not sure what you mean by the link tho? Like I said in the first post, I have already set that to 1, but the thing I don't know is where the debugging information would show up? Is it in the Serial Monitor or somewhere else I haven't heard of because nothing shows up in Serial Monitor.

xxxajk commented 6 years ago

Should appear on the serial monitor. Make sure that you do Serial.begin() first.

On Wed, Aug 15, 2018, 7:19 AM asym1 notifications@github.com wrote:

Thanks for your reply @xxxajk https://github.com/xxxajk! Not sure what you mean by the link tho? Like I said in the first post, I have already set that to 1, but the thing I don't know is where the debugging information would show up? Is it in the Serial Monitor or somewhere else I haven't heard of because nothing shows up in Serial Monitor.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/felis/USB_Host_Shield_2.0/issues/402#issuecomment-413168547, or mute the thread https://github.com/notifications/unsubscribe-auth/ADskzDd1glPR4luGAQi_CIiohNLHBqp1ks5uRAPXgaJpZM4V9351 .

xxxajk commented 6 years ago

Also make sure that you have modified the mini shield to supply 5v. The default is 3.3v, which is going to cause problems.

On Wed, Aug 15, 2018, 7:21 AM Andrew Kroll xxxajk@gmail.com wrote:

Should appear on the serial monitor. Make sure that you do Serial.begin() first.

On Wed, Aug 15, 2018, 7:19 AM asym1 notifications@github.com wrote:

Thanks for your reply @xxxajk https://github.com/xxxajk! Not sure what you mean by the link tho? Like I said in the first post, I have already set that to 1, but the thing I don't know is where the debugging information would show up? Is it in the Serial Monitor or somewhere else I haven't heard of because nothing shows up in Serial Monitor.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/felis/USB_Host_Shield_2.0/issues/402#issuecomment-413168547, or mute the thread https://github.com/notifications/unsubscribe-auth/ADskzDd1glPR4luGAQi_CIiohNLHBqp1ks5uRAPXgaJpZM4V9351 .

xxxajk commented 6 years ago

See this article for all info. https://www.circuitsathome.com/mcu/teensy-3-0-now-supported-by-the-usb-host-library/

On Wed, Aug 15, 2018, 7:23 AM Andrew Kroll xxxajk@gmail.com wrote:

Also make sure that you have modified the mini shield to supply 5v. The default is 3.3v, which is going to cause problems.

On Wed, Aug 15, 2018, 7:21 AM Andrew Kroll xxxajk@gmail.com wrote:

Should appear on the serial monitor. Make sure that you do Serial.begin() first.

On Wed, Aug 15, 2018, 7:19 AM asym1 notifications@github.com wrote:

Thanks for your reply @xxxajk https://github.com/xxxajk! Not sure what you mean by the link tho? Like I said in the first post, I have already set that to 1, but the thing I don't know is where the debugging information would show up? Is it in the Serial Monitor or somewhere else I haven't heard of because nothing shows up in Serial Monitor.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/felis/USB_Host_Shield_2.0/issues/402#issuecomment-413168547, or mute the thread https://github.com/notifications/unsubscribe-auth/ADskzDd1glPR4luGAQi_CIiohNLHBqp1ks5uRAPXgaJpZM4V9351 .

ghost commented 6 years ago

The VBUS jumper is cut and the pad is connected to the VIN of the Teensy 3.2. Serial.begin() is called in the setup of the XBOXUSB example... So I'm not sure where the printing of the debug information is going wrong

xxxajk commented 6 years ago

Connect to the vbus for the 5v. IIRC vin is diode protected, and an input only. I'll check the schematic to be certain.

On Wed, Aug 15, 2018, 7:36 AM asym1 notifications@github.com wrote:

The VBUS jumper is cut and the pad is connected to the VIN of the Teensy 3.2. Serial.begin() is called in the setup of the XBOXUSB example... So I'm not sure where the printing of the debug information is going wrong

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/felis/USB_Host_Shield_2.0/issues/402#issuecomment-413172203, or mute the thread https://github.com/notifications/unsubscribe-auth/ADskzEkxsbfjgWLUFp6p9RpnT01rOhzPks5uRAe_gaJpZM4V9351 .

xxxajk commented 6 years ago

Vin should be ok. I've always used the vbus pad. I suppose that it shouldn't matter. Have you checked the voltage on the pin?

On Wed, Aug 15, 2018, 7:39 AM Andrew Kroll xxxajk@gmail.com wrote:

Connect to the vbus for the 5v. IIRC vin is diode protected, and an input only. I'll check the schematic to be certain.

On Wed, Aug 15, 2018, 7:36 AM asym1 notifications@github.com wrote:

The VBUS jumper is cut and the pad is connected to the VIN of the Teensy 3.2. Serial.begin() is called in the setup of the XBOXUSB example... So I'm not sure where the printing of the debug information is going wrong

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/felis/USB_Host_Shield_2.0/issues/402#issuecomment-413172203, or mute the thread https://github.com/notifications/unsubscribe-auth/ADskzEkxsbfjgWLUFp6p9RpnT01rOhzPks5uRAe_gaJpZM4V9351 .

ghost commented 6 years ago

https://www.pjrc.com/teensy/schematic32.gif

Vin is directly connected to Vusb on the Teensy 3.2. I checked the Vbus on the Shield and there's 5V on there aswell.

xxxajk commented 6 years ago

Try running the boardqc to make sure that everything is ok with your wires.

On Wed, Aug 15, 2018, 7:55 AM asym1 notifications@github.com wrote:

https://www.pjrc.com/teensy/schematic32.gif

Vin is directly connected to Vusb on the Teensy 3.2. I checked the Vbus on the Shield and there's 5V on there aswell.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/felis/USB_Host_Shield_2.0/issues/402#issuecomment-413176022, or mute the thread https://github.com/notifications/unsubscribe-auth/ADskzELLZE78deBzsqY0gRGzjVQOxObNks5uRAxGgaJpZM4V9351 .

ghost commented 6 years ago

The problem is on Line 36 Usb.Init() is called before any tests are actually performed: https://github.com/felis/USB_Host_Shield_2.0/blob/master/examples/board_qc/board_qc.ino#L36

So it just gets stuck on that line. Maybe I selected a wrong option in the "Tools" section of the Arduino IDE? These are my current settings: https://gyazo.com/d82f35c2cb58a258f0d5b1634b68bcaf

gdsports commented 6 years ago

These kinds of problems are usually wrong wiring. Post a table or diagram of your wiring.

ghost commented 6 years ago

Hi @gdsports,

I think you just replied to my thread on the PJRC forum (https://forum.pjrc.com/threads/53452-USB-Host-Shield-with-Teensy-3-2). The thing is I have an older Teensy with a preloaded program which uses the exact same wiring and there the xbox controller works without an issue. That's why I doubt it's a wiring issue.

Anything else I might try?

xxxajk commented 6 years ago

As I said, try the board QC program.

ghost commented 6 years ago

@xxxajk

The problem is on Line 36 Usb.Init() is called before any tests are actually performed: https://github.com/felis/USB_Host_Shield_2.0/blob/master/examples/board_qc/board_qc.ino#L36 So it just gets stuck on that line. Maybe I selected a wrong option in the "Tools" section of the Arduino IDE? These are my current settings: https://gyazo.com/d82f35c2cb58a258f0d5b1634b68bcaf

As I said in an earlier reply. So the output of that program is literally the following:

Circuits At Home 2011 USB Host Shield Quality Control Routine Reading REVISION register... Die revision

And then it gets stuck on the Usb.Init() function

xxxajk commented 6 years ago

https://github.com/felis/USB_Host_Shield_2.0/blob/master/settings.h#L86 try changing that to a zero and see if it works. If not, then there is a wiring issue, perhaps even that your wires are too long.

ghost commented 6 years ago

@xxxajk Setting that to zero actually fixed the problem! Not sure why tho but I'm glad it's resolved!

xxxajk commented 6 years ago

Probabbly means there is a conflict with the built-in library. As far as I can remember PJRC has made the SPI faster. I'll have to look into this a bit deeper. Glad it is now working for you!

Lauszus commented 5 years ago

@xxxajk is there any reason why USE_SPI4TEENSY3 is still defined to 1 by default? A lot of improvement has happened to the SPI library including transactions etc.

wiesl commented 5 years ago

I had the same issue, but it is a compiler optimization problem (at least in my environment):

NOT OK:

OK:

it works then with the built-in SPI library as well as SPI4TEENSY3

BTW: you can use #define USE_SPI4TEENSY3 0 to use the build-in library without changing global source code

Versions:

Hardware:

greguz commented 5 years ago

Same problem here, solved by setting optimize option to fast.

Thank you @wiesl!

Software:

Hardware: