Skip to main content
Visitor II
November 23, 2022
Question

How can i set baud rate greater than 115200 for virtual com port?

  • November 23, 2022
  • 6 replies
  • 14180 views

I'm now using NUCLEO-L476RG. My PC connects to the board by virtual com port? And i try to set a baud rate greater than 115200 but the data received from usart2 is wrong. However, when i set the baud rate less than 115200, it works well.

So i wanna ask that if 115200 is the upper limitation of virtual com port? If not, how can i set a higher one?

    This topic has been closed for replies.

    6 replies

    Super User
    November 23, 2022

    virtual com port is by USB connection and runs at about 10Mbit.  baud rate setting is just a number, that has to be valid.

    and what about usart2 ? not USB obviously - so what you doing ??

    fzhan.2Author
    Visitor II
    November 23, 2022

    Actually, i just start​ learning stm32, so i am sorry i did not explain it clearly.

    I would like to transmit data from PC to stm32 and also from stm32 to PC. For the connection of PC and stm32, it is established with a usb to mini-usb cable. Affter installing the driver, there is a virtual com port in my PC, and i can send data to stm32 through the virtual com port.

    And the stm32 runs a program that receives data from and transmit data to the usart2. That is to say, when PC sends data to virtual com port, stm32 receives data from usart2; and when stm32 sends data to usart2, PC receives data from virtual com port.

    And the problem is that, 115200 is too slow for data transmission, but when i set it higher, the data will go wrong.

    Graduate II
    November 23, 2022

    Let me guess... you're only changing the baud rate on the PC side?

    If yes, that won't work, the STM32 must be set accordingly.

    Graduate
    November 23, 2022

    ST-Link VCOM works at least to 921600 b/s (surprise). Nucleo-L476 (and a bunch of few other Nucleos, mostly with STM32L MCUs) have a quirk - there is no 8 MHz clock feed from ST-Link to the MCU. To get the correct and stable baud rate you need to use PLL fed by MSI (NOT HSI16, which sems to be the current default in CubeMX), and enable the LSE oscilator. Then the CubeMX will automagically synchronize MSI to LSE. If you don't do that, remember that HAL removes the factory callibration of internal oscillators, so your clock frequency may not be too close to the nominal one.

    Super User
    November 23, 2022

    yep, thats "the about 10Mbit" , we had in our tests also.

    Super User
    November 23, 2022

    USB not active, no clk....this is your clock tree, where you complain about usb vcp speed ??

    fzhan.2Author
    Visitor II
    November 23, 2022

    yes, actually i am using usart2 to transmit data to VCP. But you are right, maybe i can try using usb for a higher speed

    Super User
    November 23, 2022

    obviously we are in different worlds . VCP IS USB , in serial mode.

    where you connect the uart ???

    fzhan.2Author
    Visitor II
    November 23, 2022

    Emm, maybe i misunderstand some concepts. Thank you for pointing it out。

    Super User
    November 23, 2022

    Virtual COM port (VCP) drivers cause the USB device to appear as an additional COM port available to the PC. Application software can access the USB device in ... (ftdi)

    fzhan.2Author
    Visitor II
    November 23, 2022

    But i wonder that what happens when stm32 sends data to usart2, even though i did not activate usb, i still receive data from VCP in PC.

    Technical Moderator
    November 23, 2022

    If you are using a development board like the NUCLEO, the ST-LINK there converts a USART to VCP, for which there is a connection from that USART to the STM32 of the ST-LINK. USB does not need to be activated for VCP to function (if it exists at all at the target).

    Regards

    /Peter

    Super User
    November 23, 2022

    aa, you using the built-in vcp of the onboard st-link.

    then your max. speed is, what this onboard thing can do; should be given somewhere in manual.

    +

    >How can i set baud rate greater than 115200...

    then you need to use the usb/device/vcp on STM32L476 chip...

    fzhan.2Author
    Visitor II
    November 23, 2022

    Thanks. I will check that