Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 10 of 10

Thread: T_40 USB Host not working

  1. #1
    Junior Member
    Join Date
    Apr 2020
    Location
    Germany
    Posts
    5

    T_40 USB Host not working

    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

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    25,045
    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.

  3. #3
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    9,561
    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();
      }
    }

  4. #4
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    15,077
    That code doesn't show anything here.

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

    That will confirm the hardware to start.

  5. #5
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    15,077
    Took me a bit to find a wired mouse … KurtE's updated example now works here as well.

  6. #6
    Junior Member
    Join Date
    Apr 2020
    Location
    Germany
    Posts
    5
    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?

  7. #7
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    15,077
    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.

  8. #8
    Junior Member
    Join Date
    Apr 2020
    Location
    Germany
    Posts
    5
    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!

  9. #9
    Junior Member
    Join Date
    Apr 2020
    Location
    Germany
    Posts
    5
    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.

  10. #10
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    15,077
    Great news. Can you post a pic to complete the solution

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •