cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F769 using both USB-HS and USB-FS in CDC (DUAL USB)

embvis
Associate III

Hi,

I need to use both USB-HS ( with external PHY USB3300) and FS in the same time (not exacly), but both have to be open as CDC at the same time. I try to use HAL, but when I add second USB, Windows doesnt recognize USB device.

Do you have working example with 2 USB.

Thanks

2 REPLIES 2
Pavel A.
Evangelist III

Yes, this was a bug in Cube - generated code when both FS and HS USBs use same host class. It looks like it still exists. It creates only one instance of the class data for both USB cores so the 2nd initialization clobbers the first. IIRC the simplest fix is to duplicate the class data immediately after its initialization, and use the copy for the 2nd USB core. Sorry, I don't have example code handy.

-- pa

embvis
Associate III

I'm using CubeMX with ne FW (1.12 and 1.11), today I make some test.

Using CubeMX for STM32F446ZE ( I have EVAL board from ST) it creates 2 instances of USB for FS and HS.

void MX_USB_DEVICE_Init(void)
{
  /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */
  
  /* USER CODE END USB_DEVICE_Init_PreTreatment */
  
  /* Init Device Library, add supported class and start the library. */
  USBD_Init(&hUsbDeviceHS, &HS_Desc, DEVICE_HS);
 
  USBD_RegisterClass(&hUsbDeviceHS, &USBD_CDC);
 
  USBD_CDC_RegisterInterface(&hUsbDeviceHS, &USBD_Interface_fops_HS);
 
  USBD_Start(&hUsbDeviceHS);
 
  /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */
  
  /* USER CODE END USB_DEVICE_Init_PreTreatment */
  
  /* Init Device Library, add supported class and start the library. */
  USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS);
 
  USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC);
 
  USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS);
 
  USBD_Start(&hUsbDeviceFS);
 
  /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */
  
  /* USER CODE END USB_DEVICE_Init_PostTreatment */
}

I encourage also some other problem. When I use Segger (STLink Reflash) example program "...STM32Cube\Repository\STM32Cube_FW_F4_V1.21.0\Projects\STM32446E_EVAL\Applications\USB_Device\DualCore_Standalone\SW4STM32\STM32446E-EVAL_USBD" USB System Device Manager shows: Windows has stopped this device because it has reported problems. (Code 43)

A request for the USB device descriptor failed.

But when I use STLink it generates 2 USB.

In this example we have one instance ?

 /* Init CDC Application */
 USBD_Init(&USBD_Device_HS, &VCP_Desc, 1);
 
  /* Init CDC Application */
 USBD_Init(&USBD_Device_FS, &VCP_Desc, 0);							
 
 /* Add Supported Classes */
 USBD_RegisterClass(&USBD_Device_HS, &USBD_CDC);
 USBD_RegisterClass(&USBD_Device_FS, &USBD_CDC);					
 
  /* Add CDC Interface Class */
 USBD_CDC_RegisterInterface(&USBD_Device_HS, &USBD_CDC_fops);
 USBD_CDC_RegisterInterface(&USBD_Device_FS, &USBD_CDC_fops);		
 
  /* Start Device Process */
 HAL_Delay(5000);
 USBD_Start(&USBD_Device_FS);
 HAL_Delay(5000);
 USBD_Start(&USBD_Device_HS);