2021-06-30 06:27 AM
I use STM32CubeIDE1.6.1 to generate USB device (CDC VCP mode) code for STM32G0B1VE. The PC could not recognize the USB. I tried internal HSI48 clock and PLLQ for USB (clock frequency verified by MCO), I pulled up DP through 1.5k resistor by a GPIO after about 2 seconds once starting the code. I'm using Windows 10. Please help!
@Imen DAHMEN
Solved! Go to Solution.
2021-07-05 03:57 AM
The Host will try to send info about the baudrate,... via USB to the device. This config needs to be saved somewhere. For some reason, the ST middleware leaves this up to the user (maybe for multiple VCOM on one chip ??). I had the same problems, and found a solution somewhere in the ST Forum. Can't remember where sadly.
Anyway, search for the file "usbd_cdc_if.c". Search for the function "CDC_Control_FS". Replace the following lines into the appropriate cases:
case CDC_SET_LINE_CODING: //a host sends the line encoding to this device, save it
tempbuf[0]=pbuf[0];
tempbuf[1]=pbuf[1];
tempbuf[2]=pbuf[2];
tempbuf[3]=pbuf[3];
tempbuf[4]=pbuf[4];
tempbuf[5]=pbuf[5];
tempbuf[6]=pbuf[6];
break;
case CDC_GET_LINE_CODING: //a host wants to read the saved encoding for this device
pbuf[0]=tempbuf[0];
pbuf[1]=tempbuf[1];
pbuf[2]=tempbuf[2];
pbuf[3]=tempbuf[3];
pbuf[4]=tempbuf[4];
pbuf[5]=tempbuf[5];
pbuf[6]=tempbuf[6];
break;
tempbuf can be static in the function scope or, as I did it, somewhere on global RAM:
/* USER CODE BEGIN PRIVATE_VARIABLES */
uint8_t tempbuf[7];
/* USER CODE END PRIVATE_VARIABLES */
Good luck!
2021-07-05 04:00 AM
In case that does not solve your problem, try downloading Wireshark. It has a powerful USB sniffer with analytics functions, which might help you.
2021-07-06 06:15 AM
If I swap DP/DM, then there will be no USB detected even. So, this is not the case. I have tried UART, GPIO, Timer and all work fine.
I don't have a USB example code to try and I don't know where I can find one.
2021-07-06 06:16 AM
Unfortunately, this doesn't work for me.
2021-07-06 08:21 AM
I have exactly the same issue.
Sometimes it work, mot 19/20 times, it won't work for me.
I try to switch USB port, then it works...then it does not work any longer.
It seems buggy?
2021-07-06 08:31 AM
I tried this too. Heap to 0x1000. No luck there as well.
I'm using STM32F373VBT.
2021-07-06 08:33 AM
Did not fix my issue either.
2021-07-06 08:48 AM
I have the same issue as you do. But for me, sometimes the PC recognize my USB device. But most of the time...no.
2021-07-06 08:53 AM
what is the uC partnumber you're using?
2021-07-06 09:03 AM
If you can connect at least once, it may caused by the noise on the cable. Make sure your cable shield is connected.
Make sure you wait long enough before you pullup the PD line.