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

Thread: USB Host polling rate issues

  1. #1

    USB Host polling rate issues


    I posted about a year ago about an issue with my mice being stuck at 500 Hz using USBHost_t36. Back then I though it could be a hardware problem.
    I unfortunatly reproduce the same issue on a teensy 4.0.

    I looked into it again and I found some very strange results. I noticed switching usb type got the usbhost to pull at 1000 hz.

    For test purposes I use a teensy 3.6 to emulate a mouse (simple mouse moves in the loop)
      Mouse.move(5, 0, 0);
      Mouse.move(0, 5, 0);
      Mouse.move(-5, 0, 0);
      Mouse.move(0, -5, 0);
    and the teensy 4.0 USBHost_t36 sample app with an extra
         static elapsedMillis pollingRateElapsedMillis;
        static int32_t pollingRateCounter;
        if (pollingRateElapsedMillis > 999) {
              Serial.printf("Hertz=%d\n", pollingRateCounter);
              pollingRateElapsedMillis = 0;
              pollingRateCounter = 0;
    in the mouse1.available() condition to measure the polling rate.

    I made a custom usb type which consists of 1 to 2 interfaces - it depends on the tests - , Mouse and Keyboard (on the teensy 3.6).
      #define VENDOR_ID		0x16C0
      #define PRODUCT_ID		0x0482
      #define MANUFACTURER_NAME	{'T','e','e','n','s','y','d','u','i','n','o'}
      #define MANUFACTURER_NAME_LEN	11
      #define PRODUCT_NAME		{'K','e','y','b','o','a','r','d','/','M','o','u','s','e','/','J','o','y','s','t','i','c','k'}
      #define PRODUCT_NAME_LEN	23
      #define EP0_SIZE		64
      #define NUM_ENDPOINTS         1 // 2 when enabling keyboard
      #define NUM_USB_BUFFERS	2
      #define NUM_INTERFACE		1 // 2 when enabling keyboard
      #define MOUSE_INTERFACE       0	// Mouse
      #define MOUSE_ENDPOINT        1
      #define MOUSE_SIZE            8
      #define MOUSE_INTERVAL        1
      /*#define KEYBOARD_INTERFACE    1	// Keyboard
      #define KEYBOARD_ENDPOINT     2
      #define KEYBOARD_SIZE         8
      #define KEYBOARD_INTERVAL     1*/
    The results are :
    Mouse only : stuck to 500 hz
    Mouse + keyboard (KEYBOARD_INTERVAL 1) : 1000 hz !! (So it can actually work at 1000 Hz!)
    Mouse + keyboard (KEYBOARD_INTERVAL 2) : 500 hz (unexpected, but this made me think the issue could actually be linked to the periodic table)

    So I checked the periodic tables for each case :

    500 hz mouse only
    Periodic Schedule:
     0: 20006200
     1: 20006200
     2: 20006200
     3: 20006200
    ... (until 31)
    1000 hz Mouse + keyboard
    Periodic Schedule:
     0: 20006200 -> 200061A0
     1: 20006200 -> 200061A0
     2: 20006200 -> 200061A0
     3: 20006200 -> 200061A0
    ... (until 31)
    500 hz Mouse + keyboard interval 2
    Periodic Schedule:
     0: 20006200 -> 200061A0
     1: 200061A0
     2: 20006200 -> 200061A0
     3: 200061A0
    ... (until 31)
    : I am not sure it works like that but 200061A0 seems to represent the keyboard, so why would it appear every line when it should be 20006200 everyline and a node with 200061A0 every 2 lines

    Any idea ? Or am I on the wrong track and the issue is somewhere else in the code ?

  2. #2
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    It has been a long time since I played in this library.

    But the first thing I would do is to turn on DEBUG stuff. Go into USBHost_tt36.h and uncomment the line:
    I would plug in your mouse and see what is printed. Example USBHIDParser::claim prints out some information like:
    endpoint information including interval.... You might see what those values are...

  3. #3
    Yes I am using debug on to try to find the issue.
    If you simply comment (or delete)
    KeyboardController keyboard1(myusb);
    the driver won't load, is not claimed by t36, the periodic table looks like a mouse only one,
    and I get the 500 hz anomaly.
    All the polling intervals, stime, ctime etc are exactly the same the only difference I see so far is the periodic table.
    I have tried a few things, like fake pipe, also checked every values around the drivers, but I can't find why usb host polls at 500 hz if no keyboard.
    I am currently thinking of creating 32 different pipes instead of an unique reference.

  4. #4
    There is definitively something strange with the t36 library.

    For the teensy mouse only exemple If I manually add the pipe_t at the second node level I manage to get a refresh rate of 1000 hz, when it is 500 hz at first node level.
    Unfortunately this dirty trick does not work on the 'real' mice, they are still stuck at 500 hz or not working.

    Another clear issue is : If I fill only the first case of the periodic table with my hid pipe, I get 32 hz which is normal (1000hz / 32).
    But If I fill 2 cases I am still stuck at 32 Hz. If I fill the 3rd one I get to 64 hz. It should be basically 32 Hz per case.

Posting Permissions

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