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

Thread: Getting USB HS performance

  1. #1
    Junior Member
    Join Date
    Jan 2022
    Posts
    1

    Getting USB HS performance

    Hi

    I have an application that requires the addition of a uart (@115200 BAUD), spi (@20MHz Clock) and gpio on a linux PC. The spi interface will be sustained bidirectional transfer of 500MB in the shortest period of time.

    I have purchased some teensy 4.0 for this purpose because of the HS USB interface and bus power (and all the peripherals are there). The idea would be use the usb serial interface to multiplex the traffic to each of the peripherals (uart, spi and gpio) from pseudoterminals. This all seems doable except that the Teensyarduino documentation curiously contains this line :
    Unlike a standard Arduino, the Teensy Serial object always communicates at 12 Mbit/sec USB speed. Many computes, especially older Macs, can not update the serial monitor window if there is no delay to limit the speed!

    On the surface this seems profoundly stupid. Someone silly enough to use an older mac to develop modern hardware projects could just buy a full speed hub and plug their teensy into that to limit transfer speeds. Whereas if this is in fact the case everyone is limited of making use of only 12Mbps on a 480Mbps USB interface. I personally would not regard this as a good thing.

    The teensyarduino documentation doesn't seem to include any other way of using the USB interface - that I can find.

    Is there an official way of using the usb hs interface?
    Is there an unofficial way of using the usb hs interface?

    thanks

  2. #2
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    10,316
    The T4.x by default will use the 480Mbps interface with 512 byte messages instead of 64 byte packets.

    There is a way in source to force it to be 12mbs...

    In usb.c: uncomment the line: //USB1_PORTSC1 |= USB_PORTSC1_PFSC; // force 12 Mbit/sec

    Edit note the product pages do mention 480...
    https://www.pjrc.com/store/teensy41.html#specs

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    26,205
    Ah, that web page writing is *very* old. I've just updated it.

    https://www.pjrc.com/teensy/td_serial.html

    When it was written, many years ago, Teensy 4.0 & 4.1 did not exist. All the earlier Teensy models only have 12 Mbit USB.

    But really, the main point of that text is the 9600 baud setting isn't used. The communication happens at the native USB speed, no matter what number you specify as the baud rate.

    The Arduino Serial Monitor has also become far more efficient than it was at the time those words were written. Much of that work occurred shortly after Teensy 4.0 release, because the extreme speed of 480 MBit/sec would hang or crash the serial monitor, especially on Windows. Today printing without any delay is still an issue with 480 speed (partly because Microsoft's drivers are buggy), but not the huge completely-crash-Arduino problem it once was.

    Hopefully the updated page is clearer?

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    26,205
    Elsewhere on that page is documentation about the flush() function from Arduino's alpha versions, before the 1.0 release so many years ago. That's how long ago this page was originally written!

  5. #5
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    15,843
    Quote Originally Posted by PaulStoffregen View Post
    Elsewhere on that page is documentation about the flush() function from Arduino's alpha versions, before the 1.0 release so many years ago. That's how long ago this page was originally written!
    Tha page ... This needs some word edit?
    Code:
    ... 
    transmit, it actual transmission occurs when the host controller allows.
    And - worthy of note on T_4.x with 480 Mbps the ideal/possible xfer is 512 not 64?:
    Code:
    On a Teensy, the entire packet, up to 64 bytes, becomes available all at once.
    and
    Code:
    ...
    single USB packet (which could have held 64 bytes)

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    26,205
    Edits made to the USB Serial page.

    https://www.pjrc.com/teensy/td_serial.html

  7. #7
    Senior Member
    Join Date
    Feb 2015
    Location
    Finland
    Posts
    241
    Quote Originally Posted by woodsend View Post
    Is there an official way of using the usb hs interface?
    Simply put, the Teensy will use USB High Speed (480 Mbit/s) if possible, and will automatically switch to USB Full Speed (12 Mbit/s) if High Speed is not available. You don't need to care at all.

    I have tested this quite a lot, because I often use a cheap ADuM3160-based USB isolator when working with my Teensy 4.0 and 4.1 stuff. These isolators are straight off the datasheet, and even in the cheap eBay copies the only difference is the isolated DC-DC converter used. However, they do not work at USB High Speed, only at Full Speed (although some have a switch to select between Full Speed and Low Speed, 1 Mbit/s). No software or hardware changes are needed: when I use the isolator, the connection is automagically downgraded to 12 Mbit/s. When I use say a normal USB hub instead, or a direct cable, the connection is 480 Mbit/s.

    (TI has an isolator chip, ISOUSB211, in preproduction, that does support high-speed USB isolation, allowing for a very similar isolator to work with USB High Speed. A member at EEVBlog forums has even designed a real-world implementation.)

    With USB Serial in Linux, you will be somewhat limited by the pseudoterminal layer. My trivial experiments can sustain something like 200 Mbit/s (25 Mbytes/sec) over USB Serial. You see, the TTY layer really isn't designed for high-throughput applications, and the various latencies in it somewhat reduces the continuous throughput due to how the USB hardware and the pseudoterminal layer work together in asynchronous fashion. However, at 20 MHz SPI clock, your data rate will be 20 Mbit/s or about 2.5 Mbytes/sec, so you should have absolutely no problem in sustaining that transfer rate over USB Serial and a pseudoterminal (or indeed more than one in parallel). You will want to treat each direction as almost a separate connection, to ensure the data flow is continuous, though.

    I do not believe you should hit any kind of bandwidth limitations with your plan using a Teensy 4.x.

    For what it is worth, my own similar usecase is using Teensy as an external framebuffer (320240 2.8" IPS panel from BuyDisplay/EastRising are my favourite), with an UART also connected to the SBC for serial console, for use with SBCs and Linux-based routers and other appliances. Just for myself as a hobby project, not a product.

Posting Permissions

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