I am programming STM32F373RCT and I have been trying to make a USB virtual comport device. if I send data up to about 960 bits per second (I used a timer (50Hz) and I transmit 14 bytes in every cycle), communication is working correctly but if I try to send data more than this, some data lost. I have to increase data transmission speed. How do I increase?
3 Answers
USB has built-in flow control so you should be able to send data as fast as possible without losing any data. There is either a bug in the USB stack you are using or in the code that you are using to send data to the USB stack. If you can identify and fix that bug, then you should be able to send data a lot faster without losing anything.
It could be the fault of the driver or related settings. One of my project that uses an STM32F103 to send data at ~600KBytes/s via USB was once done with VCP and worked fine, until a Linux kernel update. The new kernel comes with a driver that throws away data randomly at high speed, presumably due to different buffer settings.
To solve the problem, I switched to libusb
and handle all BULK packets in user space. It worked very well, both in reliability and latency (if asynchronous API is used).
I have also made STM32F103-based devices that work with flashrom
and can transfer at over 800KBytes/s over VCP without any loss or problem, so I guess it is more about the buffer setting.