What is the maximum speed of the STM32 USB CDC?

14,673

Solution 1

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.

Solution 2

  1. 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

  2. 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).

Share:
14,673
Mohammad
Author by

Mohammad

Updated on June 17, 2022

Comments

  • Mohammad
    Mohammad almost 2 years

    I'm using an STM32L151 to communicate with a PC using USB CDC. I used the STM32 HAL libraries to create my project. I found that the USB sends data in 1 ms intervals, and each time 64 bytes are being sent. So, is the maximum speed of the USB CDC 64 kbyte/s? That is much lower than the USB Full Speed data rate of 12 Mbit/s. How can I reach this speed, or at least a fraction of this speed?

  • Mohammad
    Mohammad almost 7 years
    Thanks @Turbo J. As stated before, I use HAL library, I send data to PC using the function CDC_Transmit_FS(). How should I use this function to reach 1MB/s? I have a big buffer with 2Kbyte size, However endpoint size is 64 byte. I saw in the oscilloscope that the usb send data every 1 ms. and if the CDC function uses endpoint to send data, it could send 64byte every 1ms? am I think wrong? one more question: Is there any free software to check the incoming data baud rate? thanks
  • Mohammad
    Mohammad almost 7 years
    Thanks so much for your helpful answer. So, we can say the maximum speed using the HAL libraries will be 8kB*64=512kByte/second or 4096Mbit/second? is it true? how we can reach near full speed such as 8 Mbit/s or 1MByte/s? Thanks
  • 0___________
    0___________ almost 7 years
    You need to have a bit better USB library than the one provided by STM. Remember that windows itself will limit that speed as the built in implementation of the VCOM is not very good
  • Mohammad
    Mohammad almost 7 years
    Thank again @ PeterJ. I could reach the maximum speed of 500kByte/second using the HAL libraries. Is there any trick to increase this speed using HAL libraries? Or can you introduce me better usb library than HAL libraries, please?
  • Turbo J
    Turbo J over 4 years
    You need to have the COM port open for reading in order to see anything other than the SOF every ms. Once it is open and being read, you should see a DATA token every couple of µs.