Skip to main content
lrosadev
Associate
July 7, 2016
Question

How set USB-CDC (Virtual Com Port) baudrate

  • July 7, 2016
  • 3 replies
  • 7507 views
Posted on July 07, 2016 at 18:47

Hello, I'd like to transfer some data via USB FS with Virtual Com Port (STM32F3)

Seems that baudrate is fixed to 115200 bps.

It is possible to increase this value? How?

Thank you very much

#stm32 #cdc #baudrate #vcp
This topic has been closed for replies.

3 replies

pic32user
Visitor II
October 2, 2018

check usbd_cdc_if.c -> case CDC_SET_LINE_CODING

copy&paste from there:

 /*******************************************************************************/

 /* Line Coding Structure                                                      */

 /*-----------------------------------------------------------------------------*/

 /* Offset | Field      | Size | Value | Description                         */

 /* 0     | dwDTERate  |  4 | Number |Data terminal rate, in bits per second*/

 /* 4     | bCharFormat |  1 | Number | Stop bits                           */

 /*                                       0 - 1 Stop bit                      */

 /*                                       1 - 1.5 Stop bits                   */

 /*                                       2 - 2 Stop bits                     */

 /* 5     | bParityType | 1  | Number | Parity                              */

 /*                                       0 - None                            */

 /*                                       1 - Odd                             */

 /*                                       2 - Even                            */

 /*                                       3 - Mark                            */

 /*                                       4 - Space                           */

 /* 6     | bDataBits |  1  | Number Data bits (5, 6, 7, 8 or 16).         */

 /*******************************************************************************/

Bob S
Super User
October 2, 2018

I don't believe the virtual COM port driver or the STM32 CDC code does any throttling of the data. based on the baud rate setting. Unless your STM32 is taking the data from the virtual com port and writing it to an actual UART, it does not matter WHAT baud rate you set the virtual com port to. The PC/STM32 will transfer data as fast as you feed it and/or as fast as the other end can read and process it.

Yevpator
Associate III
February 11, 2019

Hello Bob,

Hope it is ok to response on this old question.

You wrote:

"I don't believe the virtual COM port driver or the STM32 CDC code does any throttling of the data. based on the baud rate setting."

Your claim makes sense, however I actually observed a different behavior. When I open the VCP with a terminal, I need to define the baud, because the terminal is generic and do not differentiate a real COM port and a VCP. Actually, when I defined any baud lower than 115.2k it behaved as you assumed, but if I defined a higher baud the communication didn't work. I can't explain that, will try to ask the support team.

Thanks!

Werner Dähn
Associate III
October 3, 2018

Correct. You can set the baud rate in Windows to 300baud. All that happens is that during the initialization you get that information, do or not do anything with it, respond back the same value.

But the communication will still run at full USB Speed (minus what you do in the code preventing that full speed).