2018-01-09 02:35 AM
Hello everyone,
I am on an STM32F103 and I am using USB to stream data from uC (USB device, USB ) to PC. The USB connection is a virtual COM Port the Driver is standard ST driver.
I am wondering about USB performance, I measure data rates (64 Byte USB buffer size) of around 100kBytes. That's far beyond the USB 2.0 specification but I am not sure if that's a hardware problem of the STM32F103 or is there some way to optimize that. Currently I am using interrupts for the communication from uC to USB would it be better to poll data from PC? Does anyone have information about the max data rate in such a 'interrupt' driven USB communication?
best regards
Matthias
Solved! Go to Solution.
2018-01-09 05:45 PM
If you do not need compatibility with certain software on the PC side (for example to be a COM port or storage or MTD) and the PC means a WIndows machine, you can roll your own simple protocol - just open a bulk pipe and pump large blocks. On Windows side, use WinUSB API to access the device. Make a special Windows specific descriptor to skip installation of any custom drivers. But this is still about 12 Mbits, maybe consider upgrade to a chip with a HS interface.
- pa
2018-01-09 04:05 AM
The CDC 'com port' is not the protocol for best performance. You want bulk transfers, large buffers (let the USB driver split it to EP size) and queue several transfers on the PC side. Also, check that your chip actually supports HIGH SPEED mode (HS). Even if it does, an external PHY is needed. Internal PHY supports only 'full speed' ~ 12 Mbit/sec. Nevertheless, 'full speed' devices are legally USB 2.0 compliant. Cheap manufacturers shamelessly sell 'full speed' devices with 'USB 2.0' labels, hinting that they are high speed. But they aren't.
-- pa
2018-01-09 01:42 PM
Thanks for the explanations. As far as I see my device is only FS so I am limited to 12 MBit/sec. But that would be ok for my use case. But do I got you right, you're recommending to use another USB CDC class? What exactly? Mass storage device class?
2018-01-09 05:45 PM
If you do not need compatibility with certain software on the PC side (for example to be a COM port or storage or MTD) and the PC means a WIndows machine, you can roll your own simple protocol - just open a bulk pipe and pump large blocks. On Windows side, use WinUSB API to access the device. Make a special Windows specific descriptor to skip installation of any custom drivers. But this is still about 12 Mbits, maybe consider upgrade to a chip with a HS interface.
- pa
2018-01-10 07:27 AM
Ok, sounds good. But next to the bulk transfer I also need some kind of control channel to my device, e.g. to start/stop the bulk transfer. Do you have any link where to start digging to understand more about these bulk transfers? Do you know a ST example project or do you have some links that might be helpful to get started? Thank you very much.
2018-01-12 03:29 PM
>
Do you have any link where to start digging to understand more about these bulk transfers?
I'd start from learning the host application (PC) side: read on the WinUSB or LibUSB API and figure out what the device should do to make it work.
A common pattern is to have two IN pipes: interrupt and bulk. The app continuously polls on the interrupt EP because this is cheaper for the host (the USB controller does this more efficiently than polling a bulk EP). Only when you have data to send out, signal via the interrupt EP. The app then starts pumping from the bulk EP until reads all the data.
>
Do you know a ST example project
Sorry, no. Not yet.
-- pa