cancel
Showing results for 
Search instead for 
Did you mean: 

USB Superspeed Peripherals

AlEr_4025481
New Contributor II

Hi there,

I wrote a tiny app to know how many data requests can be sent (received) to (from) FX3 device. According to USB specification it must be one request per each millisecond or 1000 requests per second, but I need to be sure. So part of my EP0 callback looks like:

... 

if (SetupRequest.DirDevToHost

    && (SetupRequest.Type == (CY_U3P_USB_VENDOR_RQT >> 5))

    && (SetupRequest.Target == CY_U3P_USB_TARGET_INTF))

    {

    switch (SetupRequest.Value) {

    // Sending 16 bytes of data TO host

    case VENDOR_CONTROL_REQUEST:

    request_counter++;

    CyU3PUsbSendEP0Data(SetupRequest.Length, Ep0Buffer);

    isHandled = CyTrue;

    break;

    default:

    CyU3PDebugPrint(CY_FX_DEBUG_PRIORITY, "Unknown vendor code received (%d)\r\n", SetupRequest.Value);

    CyU3PUsbStall (0, CyTrue, CyFalse);

    }

}

if (!SetupRequest.DirDevToHost

    && (SetupRequest.Type == (CY_U3P_USB_VENDOR_RQT >> 5))

    && (SetupRequest.Target == CY_U3P_USB_TARGET_INTF))

    {

    switch (SetupRequest.Value) {

    // Receiving 16 bytes of data FROM host

    case VENDOR_CONTROL_REQUEST:

    request_counter++;

    CyU3PUsbGetEP0Data(SetupRequest.Length, Ep0Buffer, &br);

    isHandled = CyTrue;

    break;

    default:

    CyU3PDebugPrint(CY_FX_DEBUG_PRIORITY, "Unknown vendor code received (%d)\r\n", SetupRequest.Value);

    CyU3PUsbStall (0, CyTrue, CyFalse);

    }

}

...

Next, I attach FX3 to USB 3.0 port and start to send 1000 vendor requests to EP0. The result is perfect: 1000 requests in ~1000 ms.

Starting 1000 control requests from Host to Device...

  Completed in: 1007 ms

Starting 1000 control requests from Device to Host...

  Completed in: 1000 ms

But when I attach FX3 to USB 2.0 port something strange happens. Device to host requests take a lot of time: 1000 requests in ~11 seconds!

Starting 1000 control requests from Host to Device...

  Completed in: 1000 ms

Starting 1000 control requests from Device to Host...

  Completed in: 10969 ms

I have tried on different computers (desktop, laptop), on different OS'es (Windows, Linux), on different libs (libusb, libusbK), the result was the same. Finally, as I found it started to work properly when I turned off DMA multi channel. Just commented lines below and data rate from device to host has returned to normal speed.

/* Set DMA Channel transfer size */

// apiRetStatus = CyU3PDmaMultiChannelSetXfer (&DmaChInHandle, 0, 0);

// if (apiRetStatus != CY_U3P_SUCCESS)

// {

//     CyU3PDebugPrint (CY_FX_DEBUG_PRIORITY, "CyU3PDmaMultiChannelSetXfer failed, Error code = %d\r\n", apiRetStatus);

//     CyFxAppErrorHandler(apiRetStatus);

//}

And now my questions are: why this happen and how can I fix it? Source code is attached, test app for Linux based on Qt & libusb 1.0.

0 Likes
Reply
1 Solution
Rashi_Vatsa
Moderator
Moderator

Hello,

Please refer to  FX3_SDK_TroubleShooting_Guide provided with the FX3 SDK, Section 2.3, Part IV.

It mentions when FX3 is operating on a Hi Speed link, and performing concurrent IN transfers on any Bulk IN endpoint along with the EP0 IN, it is possible that the data sent on the control endpoint gets corrupted. This happens due to the endpoint block on FX3 fetching data prematurely from the DMA channel.

A workaround for this problem has been implemented in SDK versions 1.3.3 and later, where all BULK IN DMA channels are suspended for a short duration while the EP0 IN transfer is being completed. This is the reason for lower performance of the EP0 endpoint as it suspends all other IN channels every time CyU3PUsbSendEP0Data API is called.

Please refer to this thread CYUSB3013 low control read performance with FX3 SDK library versions 1.3.2 and higher  with the workaround.

Let me know if any queries on this

Regards,

Rashi

Regards,
Rashi

View solution in original post

2 Replies
Rashi_Vatsa
Moderator
Moderator

Hello,

Please refer to  FX3_SDK_TroubleShooting_Guide provided with the FX3 SDK, Section 2.3, Part IV.

It mentions when FX3 is operating on a Hi Speed link, and performing concurrent IN transfers on any Bulk IN endpoint along with the EP0 IN, it is possible that the data sent on the control endpoint gets corrupted. This happens due to the endpoint block on FX3 fetching data prematurely from the DMA channel.

A workaround for this problem has been implemented in SDK versions 1.3.3 and later, where all BULK IN DMA channels are suspended for a short duration while the EP0 IN transfer is being completed. This is the reason for lower performance of the EP0 endpoint as it suspends all other IN channels every time CyU3PUsbSendEP0Data API is called.

Please refer to this thread CYUSB3013 low control read performance with FX3 SDK library versions 1.3.2 and higher  with the workaround.

Let me know if any queries on this

Regards,

Rashi

Regards,
Rashi

View solution in original post

AlEr_4025481
New Contributor II

Hi Rashi,

Thanks a lot for your answer, now I understand why speed rate drops down.

0 Likes
Reply