USB Host Shield with Teensy 3.2

Status
Not open for further replies.
Hi all,

I'm working on "reviving" an old project someone at our university made. The basic concept is to play some basic games on an LED wall (Tetris, Snake, ...) using an Xbox 360 Controller. The person who originally made the project used a Teensy (I think it's a 3.0 ? It's a black PCB which if I'm correct stopped being made in 2015?) along with a USB Host Shield from Circuits@Home. On the 'old' Teensy there is a preloaded game, but I would like to upgrade this to make multiple games possible.

I purchased a new Teensy 3.2, so we still have the old black one as a backup incase.
I installed Arduino, Teensyduino, the USB Host Shield library, spi4teensy3 library.

I'm having a lot of issues getting the USB Shield with Xbox controller to interact with my new Teensy... I'll ask some questions regarding this to narrow down the issue.

- The pinout of the old and new Teensy should be the same, I read somewhere. Are there maybe any other changes voltage-wise that might cause the issue?

I'm using the USB Host Shield library by Oleg Mazurov (https://github.com/felis/USB_Host_Shield_2.0) and I'm using the example XBOXUSB to test the functionality (https://github.com/felis/USB_Host_Shield_2.0/blob/master/examples/Xbox/XBOXUSB/XBOXUSB.ino). In this example the code gets stuck on line 23: The Usb.Init() function never returns anything.

- Am I supposed to make any changes to the "Tools" section of the Teensyduino IDE? The USB Type is set to Serial right now?

- How would I go about trying to debug the Usb.Init() further? I have looked into the header and cpp files but must admit I'm very novice to how those are structured.

Any other suggestions to what the problem might be would be greatly appreciated!

Kind Regards

EDIT:

Something I forgot to mention: I can load programs on the "new" Teensy just fine. All the pins seem to function as advertised. However when I run the XBOXUSB Example and the code gets stuck on the line as previously mentioned (Usb.Init()) the LED lights up, which leads me to believe the SCLK signal soldered to pin 13 is constantly high? I tried looking into this online but I have no idea if this means anything useful towards debugging the issue.
 
Last edited:
Are you using a clone shield? Some have serious problems.

https://esp8266-notes.blogspot.com/2017/08/defective-arduino-usb-host-shield-boards.html

I guess Teensy 3.2 is 5V tolerant so a shield should be OK. The USB host mini board works at 3.3V so should works with any Teensy.

I doubt the usb host shield is not legit, as it works perfectly with the program that's loaded on the old Teensy..

Does anybody know if the Teensy itself might have some issues, seeing I bought if off RS components? On the website it says the manufacturer is Adafruit Industries.
 
Not sure I've seen much of the T_3.2 being counterfeited - if you look on the web at images of the T_3.2 everything should match from component size and placement to the silkscreen.

A failure in .init can be a coding problem - or compilation ordering issue.

Assuming the default Optimization is selected. Try once with DEBUG and then perhaps FAST w/LTO to see if it acts the same. That can make a difference IIRC it has on some occasions in the init code processing.

I'm not sure if the following will help debugging - but if the processor is faulting during init the lib linked below will capture that and also it will keep the USB open for output in case the failure happens and the real final message sent is not actually processed.

From this post grab that zip. Look at the example/ASSERTS. Just putting that into sketchbook/libraries will allow the fault trapping adding:

#include "debug_t3.h"

Text will be sent out USB Serial so it has to be compiled with that.

Adding this will connect the pin for flashing blink excitement if it faults : DebState(LED_BUILTIN);

Then you can drop lines like: deb_t3( 2, micros() );
Before any line and see if it was called when the fault display happens. First param is an index 0-9 for variable storage and param two is any uiint32_t number that might be meaningful at the time, in this case probably nothing.

You can look at the other examples for sample usage - they work fine unless compiled LTO as noted on post #2 on that thread because it doesn't support printf() but only Serial.printf().

If you do add this and capture a fault please post the resulting output, I'd like to see it in use so I can get on with making a thread for it.
 
Hi @ElectronicsEnthusiast!

I'm also trying to use the Teensy 3.2 with a USB host shield, https://github.com/felis/USB_Host_Shield_2.0 library and and XBOX 360 usb controller.
I'm using the USB Mini Host shield and having some issues getting the USB code to start...

Running this example code https://github.com/felis/USB_Host_Shield_2.0/blob/1.3.2/examples/Xbox/XBOXUSB/XBOXUSB.ino

On the serial monitor I just get "OSC did not start".

I tried setting
Code:
USE_SPI4TEENSY3 0
but that had no effect, which leads me to think my wiring might be wrong.

Can you share how your Teensy 3.2 is wired up or offer any suggestions?

This is the shield I'm using https://usa.banggood.com/Mini-USB-H...duino-ADK-SLR-Development-Tool-p-1175308.html
It seems to be basically the same as the Circuits at Home mini UHS, minus the jumpers.

Wired up the shield based on info here: (the pins seem to be the same as this 2.0 shield) https://www.circuitsathome.com/usb-host-shield-hardware-manual/
Wired up the Teensy based on info here: https://www.pjrc.com/teensy/td_libs_SPI.html

I also cut the trace for VBUS to supply it with 5v.

Here's how I have it wired up:

uhs_mini_teensy3.2.jpg

I wasn't sure what to do with the INT pin from the UHS. But with or without that hooked up makes no change.

Any help would be appreciated!
 
Last edited:
Hey mjs513,

That did it! Thanks!

I hadn't seen that page, still haven't read up on the differences between Teensy 3.2 and 2.0 etc

I connected INT to 9 and Reset to 3.3v, now getting good readings from the serial with the controller hooked up.

I'm not currently using the spi4teensy3 library. It will only work with

Code:
USE_SPI4TEENSY3 0

as stated above: https://github.com/felis/USB_Host_Shield_2.0/blob/master/settings.h#L86

But I'm now on to the next step. Thanks again.

Here's updated wiring for future reference:

uhs_mini_teensy3.2.jpg
 
When using a host shield this way, where Teensy's VIN pin goes directly to VBUS on the host shield, keep the USB power draw in mind.

According to the USB spec, hosts are supposed to have at least 120 uF capacitance, and devices are supposed to have at most 10 uF. The idea is to limit the voltage drop during a hot plug event, where the 120 uF cap is already at 5V and the 10 uF capacitance in the device is at 0 volts. When you plug in the cable, the 10 uF gets charged up by pulling charge away from the 120 uF.

On Teensy 3.6, we put a 100 uF capacitor (not quite the 120 uF spec) on the host port, and a current limit chip to charge it. That way, when you plug a Teensy 3.6 into your PC or a hub, its total capacitance is under the 10 uF limit, because the 100 uF isn't connected. When the USBHost_t36 library turns on the host port, the 100 uF (and any capacitance in the device, if it's already plugged in) gets charged gracefully, with a limit that hopefully doesn't disrupt the upstream host (or hub) that's powering your Teensy 3.6. If you hot-plug a device after the port is on, the 100 uF cap gives nearly all the charge to get the device up and running, dropping the voltage by about 0.5V, and then it gets recharged by a controlled current limit.

With the host shield, you don't have the current limit circuit or a big capacitor. So when you hot-plug a USB device, odds are good it will cause the 5V supply to drop down to 2-3V. Teensy might reboot. Or it might manage to run from the 3.3V capacitors, if the power disruption is short enough. If you try adding more capacitance (Teensy 3.2 has pads for this) you can sometimes improve the hot-plug situation, but you increase the load Teensy+shield+device puts on your PC or hub when you plug the cable.

There isn't any perfect answer for USB hot-plugging, when your source of power is from another USB cable. The circuit on Teensy 3.6 gets fairly close. Unfortunately, these host shields were not designed with USB power in mind, not even a place to solder an extra capacitor. Best to avoid hot plugging the USB device.
 
Thanks for the advice Paul,

I'm a programmer, but I'm quite new at hardware/circuitry!

I'm running through a powered USB hub while I'm connected to my PC for debugging and my intent was to use a separate DC power source for the actual implementation.
Do you think the power draw will still be an issue in that case?

I know just enough to be dangerous... so I am somewhat grasping in the dark, jamming things together as I learn to get things to work.

What are the risks if I do nothing to account for the draw? I assume possible damage to the Teensy, Host Shield or USB device or all of the above?
 
Status
Not open for further replies.
Back
Top