How often does / can a USB host send bulk IN packets to a device endpoint?

693 views Asked by At

I'm developing a USB MIDI device with a Teensy microcontroller - let's limit it to a USB 1.X / "Full-Speed" device for now if that helps. The USB MIDI (1.0) class definition uses Bulk transfer endpoints for communication so that's the type of transfer used.

I understand that unlike interrupt/isochronous transfers bulk transfers are not strictly limited to the frame/microframe timing - they can "fill-up" remaining bandwidth after these transfers are allowed for. Up to 19x 64-byte bulk transactions can be sent per frame (USB Full-Speed) for example according to the spec.

My questions are therefore:

  1. How often / what frequently are bulk transfers serviced by the host? (i.e. How often are BULK IN/OUT packets sent by the host)?
  2. Is this entirely defined by the host? Or can I request or ensure fastest possible servicing of transfers somehow?

Some more detail on Q1 if it helps:

I know all USB transactions are host-driven. I know the host must send an IN/OUT packet before any data is transferred. So I'm trying to confirm if the host sends BULK IN/OUT token messages every ~52ms (1000ms / 19)? Or actually at a much faster rate limited by its capabilities and the device is just expected to respond whatever this unknown rate will be.

1

There are 1 answers

0
Codo On

Provided:

  • the bandwidth is not shared (e.g. with other USB devices on the same USB bus/hub)
  • the applications on the device and on the host can source and sink the data sufficiently fast
  • only packets of the maximum size (as declared by the endpoint) are sent
  • all active endpoints transmit and/or receive data

Then the host will poll the device without any pause and you can indeed achieve up to 20 packets within a 1ms second frame (best case).

The scheduling is entirely under the control of the host, but also specified in the USB standard. So the host has limited freedom.

On the device side, you have to basically do two things:

  • Implement buffering so the USB peripheral has a packet to transmit or an available slot to receive a packet at all times. In older USB peripherals, this is solved with double buffering, in newer ones you can setup buffers for multiple packets
  • Always send packets of the maximum size. Otherwise the host is likely to pause until it polls for the next packet again.

A realistic overall throughput for a well optimized device is about 1 MByte/s.