Thanks for this wizard. This is exactly what I was looking - simply how to print from STM32F4 Discovery to serial console over Micro USB. I'm using PlatformIO (with serial monitor) in VSCode IDE.
Pretty unhelpful for anything serious. 1) you need to check to make sure the CDC isn't busy transmitting oo it will simply ignore your transmit. 2) Most CDC devices are going to need to receive data and there is nothing here about how to accomplish that or process the incoming data. This is a 6 minute video about configuring a project in CubeMX and 5 seconds of including a CDC_Transmit_FS() function call.
The main problem is, that this demo is not representativ because ST often update the MXCube, CubeIDE and the HAL library. If you ever looked into the HAL, you get shocked how bad the coding qualtity could be. Similar mention, if you look into the sources of freeRTOS. The demonstrated demo works ,if you use the HAL V1.1.2 from 23.sep.2016 and you advise the CubeMX using this old HAL. Any HAL Versions later, this does not works. I am not know why this happens, because the generated Code looks similar. But the windows system device manager could not start the registered cdc device. I had regenerate a final working version and migrate the ioc-file generated from an older version into the regular offered version of MXCube and regenerate the code for KeilMDK again. The result was similar - the new code looks very similar, but does'nt work. As a cross check, i had recompiled the old project, where the ioc.file was picked from and this works pretty nice. Well, i like the concept of the HAL- and the CMSIS libs to get the start up from scratch easiers. But teh code quality is very bad und looks that none of ST has ever heard from a common coding style. A debugging session of an unknown code with a soucre code style like freertos or HAL, is a horror task.
Thanks a lot for this video! I am moving from simpler MCUs (like C51, ARM7) where i was able to know all the internal registers and its meanings. And now I am getting messy about all this stuff in STM32. Actually, is there any simple way for to check (get noticed) about awaiting incoming character(s) on RX? And get know when TXbuffer is empty or send it byte per byte? Usualy I am using the serial while doing few other thinks. I cannot stand still until the message is sent,. My usual way was checking serial (in main while loop) like this. void Send232_2(void) { if (plssend232_2 == 0) plssend232_2 = RS232TXLENGTH; } void Serve232_2 (void) { unsigned char i=0; unsigned char c = 0x00; if (plssend232_2 > 0) { if ((COM1STA0 & BIT6) == BIT6) //if TX empty { i = RS232TXLENGTH - plssend232_2; c = strts232_2[i]; if (c != 0) { COM1TX = c; plssend232_2--; } else plssend232_2 = 0; }// eof if buffempty } //eof if plssend }
Tap into CDC_Receive_FS. It gets called whenever you receive data. Use this to check whether the TX is ready or not; USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef*)hUsbDeviceFS.pClassData; if (hcdc->TxState != 0){ return USBD_BUSY; }
@@chiptronWzCz But you can use the USB peripheral to create a composite device (multiple USB endpoints). You just can't do it with the code created by CubeMX/CubeIDE. You'll have to create the structures/code/initialization manually.
Or you can just #include "usbd_cdc_if.h" in your main and then anything else you add there gets included too. SW4STM32 looks nicer than I remember! Keil is meant to be good but I'm finding it kinda clunky tbh...
i have stm32L476RG i am trying to get 3 cdc port , i am getting some problems . if someone help me i would give more detail to solve it . Thank you , helpfull video
Hi! thanks for this tutorial. How can i increase the speed receiving data from the pc? I need about 8Mbps using STM32F103, but I can only get half that speed!
Really? How can I do to receive data from PC over virtual com port? I reach 9Mbps over USB CDC using Atmega32U4. Like STM32, AVR USB works at full-speed (12Mbps).@@chiptronWzCz
@@chiptronWzCz using seperate ULPI module connecting it to board with Externel Phy option in CubeMX? Does this configuration allow us to reach 480mbps?
Another video with no audio. Makes it impossible to follw and pretty well useless. In addition, it is now too out of date since the interface has changed.