OpenNuvoton / M031BSP

BSP for M031 Series MCU
Apache License 2.0
17 stars 15 forks source link

Reducing USB bulk transfer speed #9

Open jeromeDms opened 2 years ago

jeromeDms commented 2 years ago

Hi My app is a USB MIDI app, transfers are compliant to the USB MIDI specification, which defines BULK transfers. Each packet is 64 bytes, so each millisecond the device can receive up to 64 bytes (48 useful bytes).

Those bytes are forwarded to MIDI Out which is only 31.25 kb/sec, (as defined in MIDI specification).

When receiving large packets numbers from USB (1200 bytes of Exclusive systems for instance), incoming data must be buffered, so we have time to forward them to MIDI out at lower speed rate. Unfortunately the buffer size is limited to 1024 bytes in my app, this results in truncated data when receiving large number of USB packets.

Is there a way to reduce the USB data rate for bulk transfers (it seems the bInterval in USB descriptors can only be changed for Interrupt or Isochronous transfers). Also, it seems Nuvoton USB phy does not support USB Low speed, but only USB full speed.

Any tip to solve my issue ? thanks.

kchuang1 commented 2 years ago

Hi Per your description, your USB device use a BULK out to send data from PC to USB device, right? The BULK transfer data number is dependent on the description which you return to PC. Please check your sample rate in your USB descriptor.

By the way, USB low speed doesn't support BULK transfer. It is not your solution.

jeromeDms commented 2 years ago

You are right, I found after writing this post that USB Low speed does not support BULK. Yes BULK transfers are used in both direction, what I'm trying to do is to limit the speed from Host computer to the device. The bInterval in the device descriptor is ignored for BULK transfer, and I did not find any other solution for now.