cancel
Showing results for 
Search instead for 
Did you mean: 

USB, DMA, CDC and Speed ... Is it possible?

gareth2
Associate II
Posted on June 25, 2012 at 23:05

Hi all,

I have a fair bit of experience with the STM32 now and have got most peripherals working as I want on multiple projects but I am yet to master the USB.

I would like to transfer data collected by a series of sensors over USB to a host PC.

The key details are:-

Data load is not flat but event driven

Peak data load is around 160Mbit/s

Average data load is 60Mbit/s

So far I have managed 20Mbits/s using a modified version of the CDC example for the STM32F2x7 series (increased buffer sizes, changed output fifo to handled wrap around etc).

However 20Mbit/s seems to be my limit. Looking at the packets it looks as if the device is wasting time starting and ending transactions rather than sending continous packets

during peak flow. I am not too sure why this is as data is alwasy in the output buffer.

 Does anyone have any experience with such a project or recomendations of how I should proceed? Has anyone ported the example to work with the DMA and got better results? 

 Discussions welcome, I would just like to learn more on this.

Many Thanks,

Gareth

#stm32
1 REPLY 1
tsuneo
Senior
Posted on June 27, 2012 at 14:02

> However 20Mbit/s seems to be my limit.

Do you mean 2.5 MBytes/s?

I believe STM32F can hit more transfer speed over high-speed USB.

For CDC, keep each transfer size to slightly less than 4K bytes (for example 4095 bytes).

And then, you'll see 16 MBytes/s at least (4K transfer per every two micro-frames).

If your application can't fix the transfer size, WinUSB gives better solution than CDC.

- Assign RAW_IO pipe policy to the IN pipe

- Put more than two OVERLAPPED WinUsb_ReadPipe() in advance, before a WinUsb_ReadPipe() call comopletes.

And then, you'll see seamless IN transactions on the endpoint.

Without any change of your CDC firmware, your device is assigned to WinUSB, just by registering the device VID/PID on WinUSB INF file.

Anyway, to know which side, device or host, is responsible to the low speed performance, monitor the USB traffic on a hardware bus analyzer, once. When you see many IN-NAKs, device is too slow.

Tsuneo