T_40 USB Host not working

Status
Not open for further replies.

Fehlicks

Member
Hello friends,

my project plan: To connect my USB mouse to Teensy 4.0 via USB Host, and let the Teensy forward all incoming mouse data to the computer, like a "passthrough". I soldered a USB A Female cable to the Teensy for USB Host support.

I'm measuring ~4.78 V. The mouse lights up, but my Teensy is not getting any data.

Here's my (very simple) testing code. I'm using USBHost_t36. Is anything wrong with it maybe?

Code:
#include "USBHost_t36.h"

USBHost usbHost;
MouseController mouseController(usbHost);

void setup() {
  Serial.begin(9600);
  Serial.println("Init");
  
  usbHost.begin();
}

void loop() {
  usbHost.Task();
  if (mouseController.available())
  {
    Serial.println("Juhu!");
    mouseController.mouseDataClear();
  }
}

Let me know if you have any ideas =)
Felix
 
Most likely cause is a hardware issue. Maybe show us photos of how you connected the cable?

Or it could be something on the software side. To get much more info, edit USBHost_t36.h to enable the verbose debug info. That will at least tell you whether the library is detecting and trying to enumerate your device.
 
Did you try with the mouse example sketch?

My guess is you need to add at least one HID Controller objects like here is an updated version, I also threw in a HUB object in case you plug one in and some devices like a few keyboards have one internal. :
Code:
#include "USBHost_t36.h"

USBHost usbHost;
USBHIDParser hid1(usbHost);
USBHIDParser hid2(usbHost);
USBHub hub1(usbHost);

MouseController mouseController(usbHost);

void setup() {
  Serial.begin(9600);
  Serial.println("Init");
  
  usbHost.begin();
}

void loop() {
  usbHost.Task();
  if (mouseController.available())
  {
    Serial.println("Juhu!");
    mouseController.mouseDataClear();
  }
}
 
That code doesn't show anything here.

Start from this :: ...\hardware\teensy\avr\libraries\USBHost_t36\examples\Serial\Mouse\Mouse.ino

That will confirm the hardware to start.
 
Thanks for your replies. Unfortunately, neither the complete official example nor KurtE's program give me output. I have enabled verbose output in USBHost_t36.h. This is my output when I power up the Teensy with my USB mouse already connected to it:
Code:
Init
USB2 PLL running
 reset waited 6
USBHS_ASYNCLISTADDR = 0
USBHS_PERIODICLISTBASE = 20003000
periodictable = 20003000
port change: 14001403
    connect
  begin reset
port change: 14001005
  port enabled
And this is the output I get when disconnecting the USB mouse while Teensy is running:
Code:
port change: 1C00100A
    disconnect
disconnect_Device:
USBDriver (available_drivers) list: 20001E00 -> 20002420 -> 20002A40
USBDriver (dev->drivers) list: (empty
USBDriver (available_drivers) list: 20001E00 -> 20002420 -> 20002A40
delete_Pipe 20003400
  shut down async schedule
  Free transfers
    * 536884544 * remove * free
    * 536884352
    * 536884416 * remove * defer free until QH
  Free transfers attached to QH
    * 536884352
    * 536884416
    * 536884480
* Delete Pipe completed
removed Device_t from devlist
  disable
And this is the output I get by connecting the USB mouse again, while the Teensy is already running:
Code:
port change: 14001403
    connect
  begin reset
port change: 14001005
  port enabled
  end recovery
new_Device: 1.5 Mbit/sec
new_Pipe

I tried USB mice from two different vendors. I can post pics of my wiring later if needed. What do you guys think? :)
 
Tried here today on two different 1062 Teensy's with USB Host wiring - and others ( T4 and T_3.6 ) prior - the example code is tested to work. ANd KurtE tested to work - now and before.

Problem would seem to be hardware connect usability of the D+/D- wiring. Unless the two mice are odd - the one found and used here is a Logitech.
 
I might have soldered D+ and D- in the wrong order, maybe I got a wrong pinout for my USB cable. I will switch them and update you. Thanks!
 
Switched D+ and D- cables and everything works as expected, using KurtE's code (but without the second USBHIDParser and USBHub).

Thanks for the help and sorry for wasting your time.
 
Status
Not open for further replies.
Back
Top