‎2022-11-22 11:25 PM
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?
‎2022-11-22 11:54 PM
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 ??
‎2022-11-23 12:15 AM
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.
‎2022-11-23 12:45 AM
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.
‎2022-11-23 12:58 AM
I'm afraid not. Actually i set both baud rates of PC and stm32. And i've also set the baud rate lower than 115200 such as 9600 and 57600, and they all worked well.
By the way, i've found that there are people who with similar problems. The links are below.
NUCLEO-L152RE - Sending data at 115200 baud on USART2 kills ST-LINK VCP
‎2022-11-23 02:01 AM
ok, now i understand.
i made some speed tests on F103 , USB-> VCP and it was faster than expected;
about 10Mbit (close to the 12Mb USB "full" speed , no hub, nothing else on usb bus) , PC with XPsp2 that time, 10y ago;
just some problem was the setting of the buffers, also on XP .
so 115k is for shure not the limit, but i dont remember, what we did/adjust , to get the full speed. (at first it didnt work -- as usual. :) )
i remember, first setup was , receive data with max. speed and just throw away the received data blocks (to see, what is possible, without any delays from buffering, scanning , send to uart ... )
so try this first, to find out max. speed.
‎2022-11-23 02:16 AM
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.
‎2022-11-23 02:24 AM
yep, thats "the about 10Mbit" , we had in our tests also.
‎2022-11-23 03:17 AM
I guess that to use PLL fed by MSI is to use the settings shown in the figure. But still failed, did i do something wrong?
‎2022-11-23 03:19 AM
Well, thank you for testing. But i dont understand what i need to do. What does "receive data with max. speed and just throw away the received data blocks" means?:face_with_tears_of_joy: