Skip to main content
PPate.1
Associate III
April 2, 2025
Solved

USBX Standalone example for CDC_ACM

  • April 2, 2025
  • 2 replies
  • 1065 views

Hi,

I am implementing CDC ACM on STM32C0x series with USBX standalone. I searched for many examples but could not find a single example for USBX standalone for CDC ACM. There are examples with USBX standalone for HID Mouse. Wherever, I find example of USBX for CDC ACM, it is always using ThreadX.

Can anyone please point me to example for USBX Standalone for CDC ACM?

Thanks,

Pradeep

Best answer by Grant Bt

Here is an alternative you might consider. This is a tutorial for using the traditional USB middleware. It's for a slightly different NUCLEO, but I've tested it on a few different micros.

 

How to use STMicroelectronics classic USB device middleware with new STM32 families

 

https://community.st.com/t5/stm32-mcus/how-to-use-stmicroelectronics-classic-usb-device-middleware-with/ta-p/599274

 

The comments are interesting too, but most of the issues raised have since been fixed in the tutorial.

2 replies

Grant Bt
Grant BtAnswer
Associate III
April 2, 2025

Here is an alternative you might consider. This is a tutorial for using the traditional USB middleware. It's for a slightly different NUCLEO, but I've tested it on a few different micros.

 

How to use STMicroelectronics classic USB device middleware with new STM32 families

 

https://community.st.com/t5/stm32-mcus/how-to-use-stmicroelectronics-classic-usb-device-middleware-with/ta-p/599274

 

The comments are interesting too, but most of the issues raised have since been fixed in the tutorial.

PPate.1
PPate.1Author
Associate III
April 21, 2025

Thankyou @Grant Bt . After trying with USBX for so many days, finally I moved to classic USB device middleware as you suggested. This made it work.

Thanks,

Pradeep

Technical Moderator
April 3, 2025
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.Best regards,FBL
PPate.1
PPate.1Author
Associate III
April 3, 2025

Thanks @FBL for sharing this link. 

I have gone through this example code and I think it is implementing USB to UART bridge. In my project, application will parse the data received from USB port and do some actions and results of same will be reverted back on USB. So I do not have to implement UART related stuff. Is this understanding correct? 

In file app_usbx_device.c, function USBX_APP_Device_Init() calls following APIs:

MX_USB_OTG_HS_PCD_Init() - for my MCU, USB OTG is not supported so in my case it is MX_USB_PCD_Init(). Is this correct?

I do not have following APIs in my HAL library for my MCU:

/* Set Rx FIFO */
HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_HS, 0x200);

/* Set Tx FIFO 0 */
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 0, 0x10);

/* Set Tx FIFO 1 */
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 1, 0x10);

/* Set Tx FIFO 2 */
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 2, 0x20);

 

Instead I have following auto generated code which is not present in example code:

HAL_PCDEx_PMAConfig(&hpcd_USB_DRD_FS, 0x00, PCD_SNG_BUF, 0x0C);

HAL_PCDEx_PMAConfig(&hpcd_USB_DRD_FS, 0x80, PCD_SNG_BUF, 0x4C);

HAL_PCDEx_PMAConfig(&hpcd_USB_DRD_FS, 0x81, PCD_SNG_BUF, 0x8C);

 

is there any problem not setting Rx and Tx FIFOs? or there are some other equivalent APIs for STM32C0 MCU?

 

Thanks,

Pradeep