简体   繁体   中英

stm32f3 USB VCP working unstable

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?

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.

I found the problem. In my code, 3 timers interrupts are active and they set as high priority. USB Interrupt was set as low priority. when USB connected to computer, the new code will stop the timers' interrupts. USB communication is stable now. Thanks a lot for your comment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM