-
I've setup a USB CDC endpoint on the USB Full Speed peripheral of the STM32F407 clocked at 168 MHz. My code is based on the dual cdc example, with the second cdc interface commented out. The host is linux and the host side software is based on pyserial, and is reading one byte at a time in essentially an infinite loop. The device side code essentially just does the following in a tight loop:
Other than the USB_FS interrupt, I also have the STM32 SysClock interrupt firing every 1ms. I'm pretty sure clock interrupt handler is quite short. I'm seeing reliable transfer rates from device to host at about 72k bytes / sec. Is this a reasonable throughput? This is the configuration I'm using:
I would like to atleast be able to sustain 200 kbytes / sec and comfortably beat 1 Mbaud UART. I expect USB FS at 12 Mbits/sec should theoretically be able to manage 1 MByte/sec, or atleast sustain 500 kbytes / sec assuming a busy host, even with the CDC protocol overheads. Any suggestions of where to look for the missing bandwidth would be much appreciated. Additional Information:
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
I believe most overheads come from your host. Even with a STM32L0 @ 32MHz I achieved about 700kB/s when the host is optimized. |
Beta Was this translation helpful? Give feedback.
-
With pyserial you can read a larger chunk like 64 bytes with a timeout like 10ms, in this way there will be much less API call and keeping responsivity. |
Beta Was this translation helpful? Give feedback.
-
I've tried a better 'optimised' pyserial approach. Here are some anecdotal benchmarks on my hardware for anyone looking in the future. This is the code handling the actual usb communication. Each of these functions is run in its own thread.
|
Beta Was this translation helpful? Give feedback.
I believe most overheads come from your host. Even with a STM32L0 @ 32MHz I achieved about 700kB/s when the host is optimized.