NUCLEO-U5A5ZJ-Q USB CDC ACM maximum speed using USBx
Hi,
I am using NUCLEO-U5A5ZJ-Q board to setup a USB VCP connection with PC. I am currently using the example project CDC-ACM, and getting a maximum speed of up to 4.4MBPS via the connection by increasing the Tx FIFO size and Max Packet size in device side example code.
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 0, USBD_MAX_EP0_SIZE/4);
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 1, 1920);
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 2, USBD_CDCACM_EPINCMD_HS_MPS/4);
Since this example is for USB - UART bridge, I have removed the UART part of it and just kept the usbx_cdc_acm_write_thread_entry thread function enabled for sending data to PC. I have written a python script in windows side to receive the buffer.
I have attached the file ux_user.h for reference,
And I have increased the memory pool size or the device,
#define TX_APP_MEM_POOL_SIZE (1024*1024)
#define UX_DEVICE_APP_MEM_POOL_SIZE (500*1024)
#define USBPD_DEVICE_APP_MEM_POOL_SIZE (10000)
Also the stack size,
#define USBX_DEVICE_MEMORY_STACK_SIZE 100*1024
#define UX_DEVICE_APP_THREAD_STACK_SIZE 1024
And providing the buffer size as 32768 bytes to ux_device_class_cdc_acm_write function. I am sending 100 * 32768 bytes in a loop for checking the speed. and receiving at the PC side.
Or do I need to use the non blocking function ux_device_class_cdc_acm_write_with_callback for getting maximum throughput? Anyway I have tried that by disabling the macro UX_DEVICE_CLASS_CDC_ACM_TRANSMISSION_DISABLE and setting up the callback functions in USBD_CDC_ACM_Activate function.
/* Start Bulk transmission thread */
UX_SLAVE_CLASS_CDC_ACM_CALLBACK_PARAMETER CDC_VCP_Callback;
CDC_VCP_Callback.ux_device_class_cdc_acm_parameter_read_callback = &USBD_CDC_ACM_read_callback;
CDC_VCP_Callback.ux_device_class_cdc_acm_parameter_write_callback = &USBD_CDC_ACM_write_callback;
if (ux_device_class_cdc_acm_ioctl(cdc_acm, UX_SLAVE_CLASS_CDC_ACM_IOCTL_TRANSMISSION_START,
&CDC_VCP_Callback) != UX_SUCCESS)
{
Error_Handler();
}
Unfortunately the code goes to hardfault handler somehow. I haven't dig into it much, since I am not sure if it solves the issue with speed. Is there any example project for this callback mode if it provides a better throughput.
Is there any configuration to change in this example code so that I could get at least 10MBPS over USB HS VCP class. Or is this a limitation of the USBx USB stack? Do I need to write a separate USB stack code other than USBx provided to get more speed. I think since USB HS supports up to 480mbps, so I should get at least half of it that is 240mbps(30MBPS). What should be factor here to limit this speed in this application.
Please let me know the suggestions.
Thanks
