2025-02-07 5:48 PM - last edited on 2025-02-10 3:26 PM by Pavel A.
I have implemented a dual CDC-ACM USBX device, and would like to incorporate a mechanism to programmatically differentiate the two ACM's at the Host. One mechanism would be to have each ACM carry with it it's own Serial Number, but I am at a loss as to how to do this. The best way (I think) would be to incorporate a unique String Descriptor Table for each device. Please give me a hint as to how to do this!
Solved! Go to Solution.
2025-02-22 3:27 AM
In looking at all the examples I could find for dual ACM implementations, one portion of app_usbx_device.c are several lines that are directed at USB_FS operation:
HAL_PCDEx_PMAConfig(&hpcd_USB_FS, 0x00, PCD_SNG_BUF, 0x40);
HAL_PCDEx_PMAConfig(&hpcd_USB_FS, 0x80, PCD_SNG_BUF, 0x80);
HAL_PCDEx_PMAConfig(&hpcd_USB_FS, 0x81, PCD_SNG_BUF, 0xC0);
HAL_PCDEx_PMAConfig(&hpcd_USB_FS, 0x01, PCD_SNG_BUF, 0x100);
HAL_PCDEx_PMAConfig(&hpcd_USB_FS, 0x82, PCD_SNG_BUF, 0x140);
HAL_PCDEx_PMAConfig(&hpcd_USB_FS, 0x83, PCD_SNG_BUF, 0x180);
HAL_PCDEx_PMAConfig(&hpcd_USB_FS, 0x03, PCD_SNG_BUF, 0x1C0);
HAL_PCDEx_PMAConfig(&hpcd_USB_FS, 0x84, PCD_SNG_BUF, 0x200);
That's great - but how does this correllate to the high speed application, where I see the following structure:
HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_HS, 0x200);
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 0, USBD_MAX_EP0_SIZE/4);
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 1, USBD_CDCACM_EPIN_HS_MPS/4);
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 2, USBD_CDCACM_EPINCMD_HS_MPS/4);
These are located in the USBX_APP_Device_Init() function.
2025-02-24 1:52 PM
Is there an example of creating dual ACM's using a high speed USB OTG HAL? I can get the two to appear, and have seen the USBX FS USB instantiation. The biggest difference that I cannot map from the FS example to the HS example is that during initialization, the USB FS implementation has this sequence implemented:
/* initialize the device controller HAL driver */
MX_USB_PCD_Init();
HAL_PCDEx_PMAConfig(&hpcd_USB_DRD_FS, USBD_CONTROL_EPOUT_ADDR, PCD_SNG_BUF, 0x40);
HAL_PCDEx_PMAConfig(&hpcd_USB_DRD_FS, USBD_CONTROL_EPIN_ADDR, PCD_SNG_BUF, 0x80);
HAL_PCDEx_PMAConfig(&hpcd_USB_DRD_FS, USBD_CDCACM_EPIN_ADDR, PCD_SNG_BUF, 0xC0);
HAL_PCDEx_PMAConfig(&hpcd_USB_DRD_FS, USBD_CDCACM_EPOUT_ADDR, PCD_SNG_BUF, 0x100);
HAL_PCDEx_PMAConfig(&hpcd_USB_DRD_FS, USBD_CDCACM_EPINCMD_ADDR, PCD_SNG_BUF, 0x140);
HAL_PCDEx_PMAConfig(&hpcd_USB_DRD_FS, USBD_CDCACM2_EPIN_ADDR, PCD_SNG_BUF, 0x180);
HAL_PCDEx_PMAConfig(&hpcd_USB_DRD_FS, USBD_CDCACM2_EPOUT_ADDR, PCD_SNG_BUF, 0x1C0);
HAL_PCDEx_PMAConfig(&hpcd_USB_DRD_FS, USBD_CDCACM2_EPINCMD_ADDR, PCD_SNG_BUF, 0x200);
/* Initialize and link controller HAL driver */
ux_dcd_stm32_initialize((ULONG)USB_DRD_FS, (ULONG)&hpcd_USB_DRD_FS);
/* Start the USB device */
HAL_PCD_Start(&hpcd_USB_DRD_FS);
BUT THE HIGH SPEED IMPLEMENTS THIS:
/* Initialization of USB device */
USBX_APP_Device_Init();
HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_HS, 0x200);
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 0, USBD_MAX_EP0_SIZE/4);
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 1, USBD_CDCACM_EPIN_HS_MPS/4);
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 2, USBD_CDCACM_EPINCMD_HS_MPS/4);
In the second one, this is only a single ACM. How do you extend it to a second ACM?
2025-02-27 12:07 PM
Sorry for not getting back to you sooner. For now, I don't have a ready to use example dual CDC in HS mode. When I will have a ready to use example, I will share it with you.
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.
2025-03-05 3:13 AM - edited 2025-03-05 3:15 AM
The issue is that the fifos were not appropriately initialized. Since there was a lack of documentation, I extended the initialization at the end to read as follows:
VOID USBX_APP_Device_Init(VOID)
{
/* USER CODE BEGIN USB_Device_Init_PreTreatment_0 */
/* USER CODE END USB_Device_Init_PreTreatment_0 */
/* USB_OTG_HS init function */
MX_USB_OTG_HS_PCD_Init();
/* USER CODE BEGIN USB_Device_Init_PreTreatment_1 */
HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_HS, 0x200);
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 0, USBD_MAX_EP0_SIZE/4);
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 1, USBD_CDCACM_EPIN_HS_MPS/4);
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 2, USBD_CDCACM_EPINCMD_HS_MPS/4);
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 3, USBD_MAX_EP0_SIZE/4);
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 4, USBD_CDCACM_EPIN_HS_MPS/4);
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 5, USBD_CDCACM_EPINCMD_HS_MPS/4);
/* USER CODE END USB_Device_Init_PreTreatment_1 */
/* initialize the device controller driver*/
_ux_dcd_stm32_initialize((ULONG)USB_OTG_HS, (ULONG)&hpcd_USB_OTG_HS);
/* USER CODE BEGIN USB_Device_Init_PostTreatment */
/* USER CODE END USB_Device_Init_PostTreatment */
}
The complete USBX directory is copied for open source. This is for HS OTG, and there is no guarantee of errors since I really don't understand why it worked (lack of documentation about HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS...