cancel
Showing results for 
Search instead for 
Did you mean: 

Knowledge Base Articles

Change Bulk endpoint to Isochronous in FX3 firmware – KBA231897

Employee

Change Bulk endpoint to Isochronous in FX3 firmware – KBA231897

Version: **

Do the following to change the bulk endpoint to isochronous endpoint in FX3 firmware in applications such as the following:

  1. The application needs a guaranteed USB bandwidth.
  2. The data contains time-sensitive information.
  3. The data transfers are continuous and periodic such as an audio or video stream.

These cases differ from bulk transfers which do not guarantee USB bandwidth and are used to transfer large bursty data.

Step 1: Add an alternate setting to USB interface descriptors in the source file containing the USB descriptors that are used by the firmware. Alternate setting 0 should be with zero endpoints while alternate setting 1 should be added with the isochronous endpoints. Code 1 shows how to add an alternate setting to interface descriptors in the source file containing the USB descriptors. The cyfxbulkdscr.c file, in the GpifToUsb firmware attached with this article, is the source file containing the USB descriptors. In this example, alternate setting 0 has no endpoints, while alternate setting 1 has two endpoints.

Code 1. Modifying the USB Interface descriptors

/* Configuration descriptor */

0x09,                           /* Descriptor size */

CY_U3P_USB_CONFIG_DESCR,        /* Configuration descriptor type */

0x42,0x00,                      /* Length of this descriptor and all sub descriptors */

0x01,                           /* Number of interfaces */

0x01,                           /* Configuration number */

0x00,                           /* Configuration string index */

0x80,                           /* Config characteristics - Bus powered */

0x32,                           /* Max power consumption of device (in 8mA unit) : 400mA */

/* Interface descriptor: Interface 0, Alt setting 0 - No endpoints */       

0x09,                               /* Descriptor size */

CY_U3P_USB_INTRFC_DESCR,            /* Interface Descriptor type */

0x00,                               /* Interface number */

0x00,                               /* Alternate setting number */ //  - Alternate setting number should be set to 0              

0x00,                               /* Number of end points */                      //  - 0 endpoints under alternate setting 0

0xFF,                               /* Interface class */

0x00,                               /* Interface sub class */

0x00,                               /* Interface protocol code */

0x00,                               /* Interface descriptor string index */

/* Interface descriptor : Interface 0, Alt setting 1 – Two Endpoints */

0x09,                           /* Descriptor size */

CY_U3P_USB_INTRFC_DESCR,        /* Interface Descriptor type */

0x00,                           /* Interface number */                                    

0x01,                           /* Alternate setting number */                     //  - Alternate setting number should be set to 0 

0x02,                           /* Number of end points */                         // -  Two endpoints under alternate setting 0

0xFF,                           /* Interface class */

0x00,                           /* Interface sub class */

0x00,                           /* Interface protocol code */

0x00,                           /* Interface descriptor string index */

Note: An interface with isochronous endpoints reserves bandwidth on the USB bus. The enumeration can fail if the host cannot enable isochronous endpoints during enumeration due to bandwidth restrictions.  This can be avoided by having a default alternate (alternate setting 0) with no isochronous endpoints. When the device is not in use, the driver can switch to the default setting (alternate setting 0) to conserve bandwidth.

Step 2: Change the endpoint descriptors in the source file containing the USB descriptors. The cyfxbulkdscr.c file, in the GpifToUsb firmware attached with this article, is the source file containing the USB descriptors.

Change the endpoint type to Isochronous endpoint and configure the maximum packet size and service interval in USB endpoint descriptors.

The values of maximum packet size and service interval must be within the respective USB 3.0/ USB 2.0 specification. For example, the USB specification limits the maximum data payload size to 1023 bytes for each Full-Speed isochronous endpoint. Hi-speed and SuperSpeed endpoints are allowed up to 1024 bytes data payloads.

          

2. Configure the following parameters in SuperSpeed endpoint companion descriptors when USB SuperSpeed descriptors are used. 

         These parameters must be limited by the USB 3.0 specification.

  • Number of packets per burst
  • Number of bursts per interval
  • Data per interval

Code  2 shows the SuperSpeed isochronous endpoint descriptors:

Code 2: SuperSpeed isochronous endpoint descriptors

       /* Endpoint descriptor for producer EP */

0x07,                                                  /* Descriptor size */

CY_U3P_USB_ENDPNT_DESCR,                               /* Endpoint descriptor type */

CY_FX_EP_CONSUMER,                                     /* Endpoint address and description */

CY_U3P_USB_EP_ISO,                                     /* ISO endpoint type */              // Endpoint Type Changed to Isochronous

(CY_U3P_GET_LSB(CY_FX_ISO_MAXPKT)),                    /* LS Byte of maximum packet size. */                                                                    (CY_U3P_GET_MSB(CY_FX_ISO_MAXPKT)), /* MS Byte of maximum packet size. */

0x01,                                                  /* Servicing interval for data transfers: 1 uFrame */                               // Changed the service Interval value.

/* Super speed endpoint companion descriptor for producer EP */

0x06, /* Descriptor size */

CY_U3P_SS_EP_COMPN_DESCR,                             /* SS EP companion descriptor type */

(CY_FX_ISO_BURST - 1),                                /* Number of packets per burst. */     //Configured packets per burst (MULT)

(CY_FX_ISO_PKTS - 1),                                 /* Number of bursts per interval*/     // Configured Bursts per Intervals

(CY_U3P_GET_LSB(CY_FX_ISO_MAXPKT * CY_FX_ISO_PKTS * CY_FX_ISO_BURST)),/* LS Byte: data per interval*/ //Configured Data per Interval

(CY_U3P_GET_MSB(CY_FX_ISO_MAXPKT * CY_FX_ISO_PKTS * CY_FX_ISO_BURST)),/* MS Byte: data per interval*/ //Configured Data per Interval

Note: See the header file (cyfxgpiftousb.h) of the firmware attached with this article for the definition of the macros used in Code 2.

Step 3: Update the Length of this descriptor and all sub descriptors field of the configuration descriptor in the source file containing the USB descriptors because one alternate setting is added in the descriptors. Populate this field with the total length of the configuration descriptors which includes the following:

Length of this descriptor and all sub descriptors = Length of Configuration descriptor + Length of Interface descriptor: Interface 0, Alt setting 0 + Interface descriptor: Interface 0, Alt setting 1 + Length of Endpoint descriptor/s + Length of Super speed endpoint companion descriptor/s

Note: The length of the SuperSpeed endpoint companion descriptor is applicable only for USB SuperSpeed descriptors.

Step 4: Configure the endpoint in the main source file which implements the application by configuring the following:

  • Endpoint type – epType
  • Burst length – burstLen
  • Maximum packet size (MAXPKT)
  • Packets per burst (MULT)  – isoPkts

Notes:

  1. See the cyfxgpiftousb.c file in the GpifToUsb firmware attached with this article. This is the main source file of the attached firmware file implementing GPIF II to USB transfer.
  2. Use the workaround for the known issue mentioned Errata 4 of FX3 datasheet when isochronous data transfers are done in Hi-Speed USB.
  3. The values of packet size, packets per burst, and burst length must be limited by the respective USB 3.0/USB 2.0 specification.

Code 3: Configuring the endpoint

       epCfg.enable   = CyTrue;

        epCfg.epType   = CY_U3P_USB_EP_ISO;

        epCfg.burstLen = (usbSpeed == CY_U3P_SUPER_SPEED) ? (CY_FX_ISO_BURST) : 1;

        epCfg.streams  = 0;

        epCfg.pcktSize = (usbSpeed == CY_U3P_FULL_SPEED) ? (CY_U3P_MIN (1023, CY_FX_ISO_MAXPKT)) : CY_FX_ISO_MAXPKT;

        epCfg.isoPkts  = (usbSpeed == CY_U3P_FULL_SPEED) ? 1 : CY_FX_ISO_PKTS;

        /* Producer endpoint configuration */

        apiRetStatus = CyU3PSetEpConfig(CY_FX_EP_CONSUMER, &epCfg);

        if (apiRetStatus != CY_U3P_SUCCESS)

        {

            CyU3PDebugPrint (4, "CyU3PSetEpConfig failed, Error code = %d\n", apiRetStatus);

            CyFxAppErrorHandler (apiRetStatus);

        }

Note: Only USB endpoint 3 and endpoint 7 can be used as isochronous endpoints when the isoPkts field in the endpoint configuration is configured with a value more than 1.

Step 5: Start the application when the CY_U3P_USB_EVENT_SETINTF event is triggered with evdata (alternate setting) as 0x0001 in the USB Event Callback  function (CyFxApplnUSBEventCB) of the main source file. See the cyfxgpiftousb.c file in the GpifToUsb firmware attached with this article. This is the main source file of the attached firmware file implementing GPIF II to USB transfer.

Code 4: Starting the application

case CY_U3P_USB_EVENT_SETINTF:

/* Stop the application before restarting. */

if (glIsApplnActive)

{

CyFxApplnStop ();

}

/* Start the loop back function if alternate setting 1 has been selected. */

if (evdata == 0x0001)

CyFxApplnStart ();

break;

See the GpiftoUsb example attached with this KBA, which is modified to change the bulk endpoints to isochronous endpoints when the ISOC macro is enabled.

Note: In the firmware attached with this article, the application calls  the CyFxApplnStart () function when the CY_U3P_USB_EVENT_SETINTF event occurs. This means that the host application should select the interface with alternate setting 1. If the USB Control Center software of FX3 SDK is used, you must select alternate setting 1 manually under the device tree view.  See AN75705: Getting started with EZ-USB FX3 for information on programming and performing data transfer to FX3 using USB Control Center.

Figure 1. Selecting Alternate Setting 1

   pastedImage_9.png

You can access the USB Control Center software from <FX3 SDK Installation Path>\Cypress\EZ-USB FX3SDK\1.3\application\c_sharp\controlcenter\bin\Release.

1. Changing the bulk endpoint to isochronous in UVC firmware attached with AN75779

The changes in the UVC firmware such as that provided with AN75779 are similar to the changes described in the earlier section. The modified AN75779 firmware is attached with this article. You must enable the USE_ISOCHRONOUS_ENDPOINT macro to add an isochronous endpoint.

Note:

  • For a UVC application, the maximum bandwidth that can be achieved using the ISOC-IN endpoint under UVC for USB 3.0 in a Windows 7/8 machine is 24 Mbps because the UVC driver limits the BURST to 1 for the ISOC endpoint. However, with a Windows 10 machine, BURST can be set to 16 to achieve the maximum ISOC bandwidth.

In the attached AN75779 firmware, the isochronous endpoint is added to USB 3.0 descriptors only. Using isochronous endpoints in USB 2.0 for a UVC application is not recommended because the maximum USB bandwidth supported by FX3 will be ~8 MBps (1 KB packet per 125 µs). This is because you should use the CY_FX_ISO_PKTS (MULT) setting as ‘1’ for USB Hi-Speed UVC applications with the FX3 device to prevent the known issue of Invalid PID Sequence in USB 2.0 ISOC data transfer mentioned in Errata 4 of the FX3 datasheet.

Attachments
0 Likes
Version history
Revision #:
1 of 1
Last update:
‎Dec 22, 2020 08:12 PM
Updated by:
 
Contributors