I'm using stm32L151 to communicate with PC by USB CDC. I used stm32 HAL libraries to create my project. I found that the usb sends data in 1ms intervals and each time, 64 bytes is being sent. So, is the maximum speed of the USB CDC is 64kbyte/s? and this speed is very lower than the USB full speed 12Mbit/second. How I can reach this speed? or at least a fraction of this speed? Thanks
2 Answers
5
votes
Nope. If your code is "fast enough", the maximum CDC speed is about 1MByte/sec
. This may require a big (>1KB) FIFO on the device side. Oh, and the PC side must be able to read the data fast enough, e.g. with big buffers.
The 64KByte/s limit applies for USB HID which uses interrupt endpoints. USB CDC interface uses faster bulk endpoints.
3
votes
USB FS frame is 1ms so if you put 64 bytes to the buffer (using the HAL function) - it will send those 64 bytes in the next frame. And it will not send any more data until another 1ms frame
How to increase this speed -> aggregate your data in larger chunks and send more data in the one transaction (up to 8kB using HAL libraries).