8 years, 1 month ago.

LPC1768 Full speed USB raw data transfers

I'm reading measurements from a sensor via SPI. From this sensor I'm getting a 19kByte framebuffer at about 12 frames per second. Now I'd like to send this framebuffer to a PC via USB for further processing. Are there any existing embed libraries capable of doing this at similar frame rates?

USBSerial is far too slow, taking multiple seconds for a single frame. The USBAudio examples do come near the required bit rate but since I'm not actually sending audio I'm hesitating to use it.

Are there any libraries made for raw data streaming at speeds above 200kByte/s?

1 Answer

8 years, 1 month ago.

The issue is with host side drivers. Do you want to write a custom bulk driver? Windows & Linux provide drivers for USB CDC class which uses bulk transport. Both can handle data rates you specify. Full speed USB is limited by packet size (64 bytes) and the polling interval (1ms and 19 MAX frames) you will have to pack data into each transfer so that every transfer is a full 64 bytes and have enough data to send as much as possible per frame. You may want to look into using DMA for both USB and SPI because there can be no blocking code anywhere.

I can't afford the time to write my own drivers at this time, unfortunately. If there are no existing solutions I will have to make some compromises with what I'm sending through.

This could be an option for future projects, however. Looking at the USBSerial library, I can see it is using an implementation of USB CDC. What is causing it to write at such low speeds, then? If you can point me to some resources to adept or write a new USB CDC library I would greatly appreciate it.

posted by Tom N 01 Apr 2016

I have not used USB on mbed as of yet so I do not know the problems you are facing. you can mix mbed code and code from outside the mbed circle. https://www.lpcware.com/ has a LPC17xx USB driver stack and an example for CDC class. You still may have to tweak things.

Another route is to use an LPC1800 series which has a USB High Speed phy. Then you are pushing 512 byte packets and will not have any issues.

you may want to look into libusb or alternatives to it if you really want to go down the custom route.

Shouldn't have to, CDC on most modern PC's should handle your rates. On Windows CDC, the default buffer is only 2K, but you should increase it to 1MB or more via SetupComm() (WIN32) or SerialPort.ReadBufferSize (,NET). That should improve things.

posted by David Thedens 01 Apr 2016