cancel
Showing results for 
Search instead for 
Did you mean: 

STM32C0 USB CDC not working

PPate.1
Associate III

Hi,

I am using custom board with STM32C071. I am trying to enable USB port with CDC so that my custom board will be visible as virtual com port on PC. After enabling all options and initializations, I was expecting that my board will appear on PC device manager COM port list but it does not appear. Below are the settings:

1. Clock configuration - In my hardware external crystal is connected of 8MHz and I see there is no PLL which can multiply it and hence I am using internal 48MHz clock.

PPate1_0-1742920922538.png

2. USB port is enabled with default settings. PA11 and PA12 pins are used for USB connection in hardware. USB global interrupt is enabled.

PPate1_1-1742921070309.png

3. USBX is enabled from middleware. Device class CDC ACM is only one selected.

PPate1_2-1742921196299.png

4. Most of the settings for USBX is default value except for two of them marked in red color. These values are updated from 1024 to 10000 and 512 to 8000. With default values of 1024 and 512, function MX_USBX_Device_Init() was returning error. After referring to discussions on community, I got one of the reference to make this change which resolve the error of MX_USBX_Device_Init(). However, still my board is not visible on PC as VCP.

PPate1_3-1742921907090.png

Hardware schematic is as follows:

PPate1_4-1742922370961.png

In main.c file, I could see following two function calls:

MX_USB_PCD_Init();

MX_USBX_Device_Init();

Both of the above functions return 'success'.

Please guide me in locating the issue as why my custom board is not appearing as VCP on PC.

Thanks,

Pradeep

edit: updated label STM32C0 Series

 

12 REPLIES 12
PPate.1
Associate III

Hi FBL,

I recopied the example project in my workspace and now i could compile it. However, I need to include ThreadX middleware in the project else it gives errors in file 'app_usbx_device.c'. All errors are related to ThreadX. 

After downloading to Nucle-C071 board it does not appear as VCP on my PC. I added 'HAL_PCD_Start(&hpcd_USB_DRD_FS);' function call after all initialization functions and before MX_ThreadX_Init();.

After this I started getting message on my PC as 'USB device not recognised'. As per some discussion on community related to this error, I tried updating Heap memory size from 0x200 to 0x1000 but it does not resolve my issue.

In Device manager on my PC I can see new USB device under 'Universal Serial Bus Controllers' as 'Unknown USB device (Device Descriptor Request Failed)'. 

Hardware: You can look at layout image I have posted in this thread above. ESD diodes are kept near to connector. I am not using power switch as my device is going to be self powered and work in device mode only.

Please guide further to resolve this issue.

Thanks,

Pradeep

Hi,

There is no example for CDC_ACM in standalone configuration and hence I took another example from Nucleo-C071 folder - Ux_Device_HID_Standalone. I could build and download this example on my Nucleo board and I could see it is executing good. On my PC, device manager shows 'HID Compliant Mouse' in Mice and Pointing devices group.

I took this as reference and made a copy and updated it to remove HID Mouse options and selected CDC_ACM. For USBX settings, I took reference from Ux_Device_CDC_ACM (not sure if this is correct way of doing it). This got successfully executed on my Nucleo Board and in device manager on my PC, it shows USB serial Device (COMxx). 

I used this as reference to update my custom board project settings for USBX. I connected USB port of my custom board to my PC and downloaded the project. I could see 'USB serial Device (COMxx)' on my PC device manager apart from 'STMicroelectronics STLink Virtual ComPort' and I thought things are resolved.

However, I was wrong. I am using ST Link from Nucleo-G0B1RE board (another Nucleo board) for downloading code into my custom board. When i removed USB cable of this Nucleo board, both STLink VCP and USB serial device on my PC was removed. I reconnected its USB cable and observed that both serial ports appeared again. Now I removed USB cable of my Custom board and to my surprise, again USB serial device on my PC was removed but STLink VCP was appearing. Now I am unable to understand, what's going on here!!!

My setup diagram is as below:

PPate1_0-1743413779068.png

Removing any of the USB cable in above setup, leads Windows 11 on my PC to remove USB serial device appearing in device manager. I tried without USB hub too, results are same. I tried connecting only Custom Board or only Nucleo-G0B1RE board and observed that in either case, USB serial device does not appear on PC. I also tried connecting both with PC but disconnected 5-pin downloading cable and observed that USB port does not appear on PC. It appears only when complete setup shown in above diagram is connected and powered up.

Please help me in understanding this scenario and resolving the problem as I want my custom board USB port to appear as COM port on PC (offcourse without STLink).

Hi,

Can anyone please reply to my queries?

Thanks,

pradeep