Hello,
我想要的to transmit a big amount of data to USB. I am using USB_CDC example project for this but with this example the throughput is about 700 KBps. Is there any way to speed up the USB CDC throughput? Does the DMA helpful? If yes, How to initialize and use DMA with USB_CDC?
Thank you in Advance.
Keywords:
Device:
Hi techteh,
In order to achieve max possible performance for USB you should use the 1.0.14 SDK and do the following changes:
1) In the file hw_usb.c, in the function hw_usb_init() change as follows:
REG_SET_FIELD(USB, USB_MAMSK_REG, USB_M_NAK, reg, 1);
REG_SET_FIELD(USB, USB_MAMSK_REG, USB_M_FRAME, reg, 1);
To:
REG_CLR_FIELD(USB, USB_MAMSK_REG, USB_M_NAK, reg);
REG_CLR_FIELD(USB, USB_MAMSK_REG, USB_M_FRAME, reg);
2) Enable the DMA by setting in the custom_config_qspi.c the macro:
#define dg_configUSB_DMA_SUPPORT (1)
Thanks MT_dialog
Hi,
Thanks for your reply,
I did everything that you said, but nothing changed. The throughput is still about 700 KBps.
Is there anything wrong with my code (for transmit a large of data). Here it is:
USBD_CDC_Write(hInst, Transmit_Buffer, 2000, 0);
Thanks.
Hi techteh,
Could you please clarify if you are using the default CDC or you did any modifications? If you are using the default CDC, this is only for loopback and not for performance because it is single task implemented and it uses only one task for both USB receive and USB transmit. If you want to increase the performance, it is highly recommended to use two different tasks for USB receive and USB transmit.
Thanks, PM_Dialog
Hi,
Thanks for your reply,
I was using the default CDC before your helps. Now I am using two task for this problem, one for RX and one for TX, but still nothing changed.
I have attached my modified USB_CDC.c file.
Thanks.
minor-latin;mso-bidi-theme-font:minor-latin;background:white;mso-ansi-language:
EN-US">Hitechteh,
minor-latin;mso-bidi-theme-font:minor-latin;background:white;mso-ansi-language:
EN-US">I am checking your code and I will let you know as soon as possible.
minor-latin;mso-bidi-theme-font:minor-latin;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm;background:white;mso-ansi-language:
EN-US">Thanks, PM_Dialog mso-ascii-theme-font:minor-latin;mso-hansi-theme-font:minor-latin;mso-bidi-theme-font:
minor-latin;background:white;mso-ansi-language:EN-US">
Hiparamvir.in@gmail.com,
The throughput will not be changed, since your physical mean of data transfer is the UART protocol. So, the maximum throughput you can achieve using the CDC class is 700Kbps. The double task implementation is the right way for achieving the maximum throughput.
Thanks, PM_Dialog