1 2 3 4 Previous Next 47 Replies Latest reply on Nov 15, 2019 11:32 AM by maVa_1182686 Go to original post
      • 15. Re: Issues with isoc.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k], ref pktsInfo[k]))
        HemanthR_06

        Hi,

         

        Can you please let me know what is the problem with the FinishDataXfer() call with respect to those small packets? (Did the call fail?)

         

        Regards,

        Hemanth

        • 16. Re: Issues with isoc.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k], ref pktsInfo[k]))
          maVa_1182686

          I'm not sure what's happening. As you know, i have a simple counter in the data. That is how I know that the content of the smaller packages is completely logical and correct coming from the FPGA => FX3 => host (wireshark)

           

          When read the data with the FinishDataXfer() function the data seems to be there at least partially...but the order is completely random.

           

          As i Increase a counter in the data  from x0000 to x00FF in 0001 increments, every 1024 bytes.

          You expect to see that reflected in the data. Every new 1024 bytes the counter has to increase.

           

          You see this happen perfectly fine in wireshark.

          The data coming from FinishDataXfer() is random. It's all over the place jumping seemingly random from one number to the next.

          • 17. Re: Issues with isoc.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k], ref pktsInfo[k]))
            maVa_1182686

            (but the data IS a counter...so it IS the data from the FPGA...it's not random data as such...it's just that the order in which it comes out of FinishDataXfer() is non sensical)

            • 18. Re: Issues with isoc.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k], ref pktsInfo[k]))
              HemanthR_06

              Did you make sure that there is no error with respect to any index of the Finish circular queue and that you are looking at the data in the right order? Can you please share your code?

               

              Regards,

              Hemanth

              • 19. Re: Issues with isoc.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k], ref pktsInfo[k]))
                maVa_1182686

                I assume that when

                  if (isoc.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k], ref pktsInfo[k]))

                 

                len > 0

                 

                the data at the start of xBufs[k] is the correct data from position 0 to position len

                 

                For the moment i don't really do anything with it other than printing it to the console to check if it's correct.

                 

                  if (isoc.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k], ref pktsInfo[k]))

                                    {

                                        //XferBytes += len;

                                        //Successes++;

                 

                 

                 

                 

                                        Console.WriteLine("length pkts=");

                                        Console.WriteLine(len.ToString());

                                        PacketLength = len;

                 

                 

                                        ISO_PKT_INFO[] pkts = pktsInfo[k];

                 

                 

                                        for (int j = 0; j < PPX; j++)

                                        {

                                            if (pkts[j].Status == 0)

                                            {

                                                XferBytes += pkts[j].Length;

                 

                 

                                                Successes++;

                                            }

                                            else

                                                Failures++;

                 

                 

                                            pkts[j].Length = 0;

                                        }

                                        USBpacket = xBufs[k];

                                        //for (int i = 0; i < PacketLength / 1024; i++)

                                        if (PacketLength > 0)

                                       

                                        {

                                                    int a = 0;

                                                    Console.WriteLine("test:");

                                                    for (int i = 0; i < 8; i++)  //8 packets per Xfer

                                                    {

                                                          a = (USBpacket[ i * 1 * 4096]);  //scanning the data to see if every 1024 bytes there is an increment

                                                          Console.WriteLine((a/4).ToString());   //devide the incremented data by 16 to remove increment of 16 and make it increment of 1

                                              

                                                    }

                 

                                                  

                 

                 

                 

                                         }

                }

                 

                 

                This is the code i used to test the firmware with 4 bursts of 1024 (4kB DMA buffer size)

                I always expect 32kB chunks but in the problematic case where the fpga is held back and incomplete (<32kB ) are sent I still plot the entire xBuf, just to try to see the pattern in the data.

                 

                The fpga data counter is put in int a and as the DMA is 4kB large...the data is incremented 4 times in one 4kB packet.

                That's why i divide a by 4 so I can clearly see if the data was correct 1,2,3,4,...,64,1,2,3,4,...,64,, or incorrect...1,2,3,4,55,56,57,58,22,23,24,25

                 

                How are you supposed to work with xBuf when data is not complete????

                • 20. Re: Issues with isoc.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k], ref pktsInfo[k]))
                  HemanthR_06

                  Hi,

                   

                  1. When you mention "4 bursts of 1024" is the burst setting in the descriptor 4? What is the mult setting at that time? - It would be helpful if you post the endpoint descriptor and its companion descriptor?

                   

                  2. Regarding your comments:

                  "

                  When

                  len > 0

                  the data at the start of xBufs[k] is the correct data from position 0 to position len"

                  >> Lets take an example when k=1 and len = 2048

                  I think you are aware that you can check USBpacket[] from index 0 to 2047 (since the length of the data returned for this particular Finish is 'len').

                  When you mentioned - "I still plot the entire xBuf, just to try to see the pattern in the data." did you check for xBuf[1] past USBPacket[2047]?

                   

                  3. Can you put 'else' statement to the if(isoc.FinishDataXfer) and check if there were any failures?

                   

                  Regards,

                  Hemanth

                  • 21. Re: Issues with isoc.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k], ref pktsInfo[k]))
                    maVa_1182686

                    I check for failures with the normal streamer code:

                     

                    for (int j = 0; j < PPX; j++)

                                            {

                                                if (pkts[j].Status == 0)

                                                {

                                                    XferBytes += pkts[j].Length;

                     

                     

                                                    Successes++;

                                                }

                                                else

                                                    Failures++;

                     

                     

                                                pkts[j].Length = 0;

                                            }

                     

                    There are no failures.

                     

                     

                     

                    When len = 2048 i assume indeed that when USBpacket = xBuf[k], USBpacket[0] => USBpacket[2047]

                    Is the correct data. This is not the case.

                     

                    I check the complete xBUF just to try to see a pattern...if there would be one.

                    I always check the entire thing (and like you asked indeed past your hypothetical 2048) just to be sure.

                     

                    It is NOT the case that the data is OK in the zone indexed by [0..len] and not OK outside.

                    That would make sense but it is not the case.

                     

                     

                    I use, There is no multiplier:

                    #define CY_FX_ISOSRC_DMA_BUF_COUNT      (16)    /* Number of buffers in the DMA channel. */

                    #define CY_FX_ISO_PKTS                  (1)    /* Number of bursts per microframe. */

                    #define CY_FX_ISO_BURST                (4)    /* Number of packets per burst. */

                     

                    (this code works perfectly when all packets are 32kB - when put differently, the FPGA is not held back and can saturate the GPIFII)

                     

                     

                    and for descriptors:

                     

                     

                    /*

                    ## Cypress USB 3.0 Platform header file (cyfxisodscr.c)

                    ## ===========================

                    ##

                    ##  Copyright Cypress Semiconductor Corporation, 2010-2018,

                    ##  All Rights Reserved

                    ##  UNPUBLISHED, LICENSED SOFTWARE.

                    ##

                    ##  CONFIDENTIAL AND PROPRIETARY INFORMATION

                    ##  WHICH IS THE PROPERTY OF CYPRESS.

                    ##

                    ##  Use of this file is governed

                    ##  by the license agreement included in the file

                    ##

                    ##    <install>/license/license.txt

                    ##

                    ##  where <install> is the Cypress software

                    ##  installation root directory path.

                    ##

                    ## ===========================

                    */

                     

                     

                    /* This file contains the USB enumeration descriptors for the ISO source application example.

                    * The descriptor arrays must be 32 byte aligned and multiple of 32 bytes if the D-cache is

                    * turned on. If the linker used is not capable of supporting the aligned feature for this,

                    * either the descriptors must be placed in a different section and the section should be

                    * 32 byte aligned and 32 byte multiple; or dynamically allocated buffer allocated using

                    * CyU3PDmaBufferAlloc must be used, and the descriptor must be loaded into it. The example

                    * assumes that the aligned attribute for 32 bytes is supported by the linker. Do not add

                    * any other variables to this file other than USB descriptors. This is not the only

                    * pre-requisite to enabling the D-cache. Refer to the documentation for

                    * CyU3PDeviceCacheControl for more information.

                    */

                     

                     

                    #include "cyfxslfifosync.h"

                     

                     

                    /* Standard device descriptor for USB 3.0 */

                    const uint8_t CyFxUSB30DeviceDscr[] __attribute__ ((aligned (32))) =

                    {

                        0x12,                          /* Descriptor size */

                        CY_U3P_USB_DEVICE_DESCR,        /* Device descriptor type */

                        0x10,0x03,                      /* USB 3.1 */

                        0x00,                          /* Device class */

                        0x00,                          /* Device sub-class */

                        0x00,                          /* Device protocol */

                        0x09,                          /* Maxpacket size for EP0 : 2^9 */

                        0xB4,0x04,                      /* Vendor ID */

                        0xF1,0x00,                      /* Product ID */

                        0x00,0x00,                      /* Device release number */

                        0x01,                          /* Manufacture string index */

                        0x02,                          /* Product string index */

                        0x00,                          /* Serial number string index */

                        0x01                            /* Number of configurations */

                    };

                     

                     

                    /* Standard device descriptor for USB 2.0 */

                    const uint8_t CyFxUSB20DeviceDscr[] __attribute__ ((aligned (32))) =

                    {

                        0x12,                          /* Descriptor size */

                        CY_U3P_USB_DEVICE_DESCR,        /* Device descriptor type */

                        0x10,0x02,                      /* USB 2.10 */

                        0x00,                          /* Device class */

                        0x00,                          /* Device sub-class */

                        0x00,                          /* Device protocol */

                        0x40,                          /* Maxpacket size for EP0 : 64 bytes */

                        0xB4,0x04,                      /* Vendor ID */

                        0xF1,0x00,                      /* Product ID */

                        0x00,0x00,                      /* Device release number */

                        0x01,                          /* Manufacture string index */

                        0x02,                          /* Product string index */

                        0x00,                          /* Serial number string index */

                        0x01                            /* Number of configurations */

                    };

                     

                     

                    /* Binary device object store descriptor */

                    const uint8_t CyFxUSBBOSDscr[] __attribute__ ((aligned (32))) =

                    {

                        0x05,                          /* Descriptor size */

                        CY_U3P_BOS_DESCR,              /* Device descriptor type */

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

                        0x02,                          /* Number of device capability descriptors */

                     

                     

                        /* USB 2.0 extension */

                        0x07,                          /* Descriptor size */

                        CY_U3P_DEVICE_CAPB_DESCR,      /* Device capability type descriptor */

                        CY_U3P_USB2_EXTN_CAPB_TYPE,    /* USB 2.0 extension capability type */

                        0x1E,0x64,0x00,0x00,            /* Supported device level features: LPM support, BESL supported,

                                                          Baseline BESL=400 us, Deep BESL=1000 us. */

                     

                     

                        /* SuperSpeed device capability */

                        0x0A,                          /* Descriptor size */

                        CY_U3P_DEVICE_CAPB_DESCR,      /* Device capability type descriptor */

                        CY_U3P_SS_USB_CAPB_TYPE,        /* SuperSpeed device capability type */

                        0x00,                          /* Supported device level features  */

                        0x0E,0x00,                      /* Speeds supported by the device : SS, HS and FS */

                        0x03,                          /* Functionality support */

                        0x00,                          /* U1 Device Exit latency */

                        0x00,0x00                      /* U2 Device Exit latency */

                    };

                     

                     

                    /* Standard device qualifier descriptor */

                    const uint8_t CyFxUSBDeviceQualDscr[] __attribute__ ((aligned (32))) =

                    {

                        0x0A,                          /* Descriptor size */

                        CY_U3P_USB_DEVQUAL_DESCR,      /* Device qualifier descriptor type */

                        0x00,0x02,                      /* USB 2.0 */

                        0x00,                          /* Device class */

                        0x00,                          /* Device sub-class */

                        0x00,                          /* Device protocol */

                        0x40,                          /* Maxpacket size for EP0 : 64 bytes */

                        0x01,                          /* Number of configurations */

                        0x00                            /* Reserved */

                    };

                     

                     

                    /* Standard super speed configuration descriptor */

                    const uint8_t CyFxUSBSSConfigDscr[] __attribute__ ((aligned (32))) =

                    {

                        /* Configuration descriptor */

                        0x09,                          /* Descriptor size */

                        CY_U3P_USB_CONFIG_DESCR,        /* Configuration descriptor type */

                        0x3E,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 0, Alt. Setting 0: No endpoints */

                        0x09,                          /* Descriptor size */

                        CY_U3P_USB_INTRFC_DESCR,        /* Interface Descriptor type */

                        0x00,                          /* Interface number */

                        0x00,                          /* Alternate setting number */

                        0x00,                          /* Number of end points */

                        0xFF,                          /* Interface class */

                        0x00,                          /* Interface sub class */

                        0x00,                          /* Interface protocol code */

                        0x00,                          /* Interface descriptor string index */

                     

                     

                        /* Interface 0, Alt. Setting 1: One ISO IN endpoint with single burst per uFrame. */

                        0x09,                          /* Descriptor size */

                        CY_U3P_USB_INTRFC_DESCR,        /* Interface Descriptor type */

                        0x00,                          /* Interface number */

                        0x01,                          /* Alternate setting number */

                        0x01,                          /* Number of end points */

                        0xFF,                          /* Interface class */

                        0x00,                          /* Interface sub class */

                        0x00,                          /* Interface protocol code */

                        0x00,                          /* Interface descriptor string index */

                     

                     

                        /* Endpoint descriptor for IN 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 */

                        0x00,0x04,                      /* Max packet size = 1024 bytes */

                        0x01,                          /* Servicing interval for data transfers : 1 uFrame */

                     

                     

                        /* Super speed endpoint companion descriptor. */

                        0x06,                          /* Descriptor size */

                        CY_U3P_SS_EP_COMPN_DESCR,      /* SS endpoint companion descriptor type */

                        (CY_FX_ISO_BURST - 1),          /* Max no. of packets in a burst(0-15) - 0: burst 1 packet at a time */

                        0,                              /* Only one 16KB burst per micro-frame. */

                        0x00, (0x04 * CY_FX_ISO_BURST), /* Bytes per interval : 1024 * 1 * burst */

                     

                     

                        /* Interface 0, Alt. Setting 2: One ISO IN endpoint with multiple bursts per uFrame. */

                        0x09,                          /* Descriptor size */

                        CY_U3P_USB_INTRFC_DESCR,        /* Interface Descriptor type */

                        0x00,                          /* Interface number */

                        0x02,                          /* Alternate setting number */

                        0x01,                          /* Number of end points */

                        0xFF,                          /* Interface class */

                        0x00,                          /* Interface sub class */

                        0x00,                          /* Interface protocol code */

                        0x00,                          /* Interface descriptor string index */

                     

                     

                        /* Endpoint descriptor for consumer 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 */

                        0x00,0x04,                      /* Max packet size = 1024 bytes */

                        0x01,                          /* Servicing interval for data transfers : 1 uFrame */

                     

                     

                        /* Super speed endpoint companion descriptor. */

                        0x06,                          /* Descriptor size */

                        CY_U3P_SS_EP_COMPN_DESCR,      /* SS endpoint companion descriptor type */

                        (CY_FX_ISO_BURST - 1),          /* Max no. of packets in a burst(0-15) - 0: burst 1 packet at a time */

                        (CY_FX_ISO_PKTS - 1),          /* Mult.: Max number of packets : CY_FX_ISO_PKTS */

                        0x00,(0x04 * CY_FX_ISO_PKTS * CY_FX_ISO_BURST), /* Bytes per interval : 1024 * isoPkts * burst */

                    };

                     

                     

                    /* Standard high speed configuration descriptor */

                    const uint8_t CyFxUSBHSConfigDscr[] __attribute__ ((aligned (32))) =

                    {

                        /* Configuration descriptor */

                        0x09,                          /* Descriptor size */

                        CY_U3P_USB_CONFIG_DESCR,        /* Configuration descriptor type */

                        0x22,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 2mA unit) : 100mA */

                     

                     

                        /* 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 */

                        0x00,                          /* Number of endpoints */

                        0xFF,                          /* Interface class */

                        0x00,                          /* Interface sub class */

                        0x00,                          /* Interface protocol code */

                        0x00,                          /* Interface descriptor string index */

                     

                     

                        /* Interface 0, Alt. Setting 1: ISO IN endpoint. */

                        0x09,                          /* Descriptor size */

                        CY_U3P_USB_INTRFC_DESCR,        /* Interface Descriptor type */

                        0x00,                          /* Interface number */

                        0x01,                          /* Alternate setting number */

                        0x01,                          /* Number of endpoints */

                        0xFF,                          /* Interface class */

                        0x00,                          /* Interface sub class */

                        0x00,                          /* Interface protocol code */

                        0x00,                          /* Interface descriptor string index */

                     

                     

                        /* Endpoint descriptor for consumer 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 */

                        0x00,(0x04 | ((CY_FX_ISO_PKTS - 1) << 3)),  /* Max packet size = 1024 bytes, mult CY_FX_ISO_PKTS */

                        0x01                            /* Servicing interval for data transfers */

                    };

                     

                     

                    /* Standard full speed configuration descriptor */

                    const uint8_t CyFxUSBFSConfigDscr[] __attribute__ ((aligned (32))) =

                    {

                        /* Configuration descriptor */

                        0x09,                          /* Descriptor size */

                        CY_U3P_USB_CONFIG_DESCR,        /* Configuration descriptor type */

                        0x22,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 2mA unit) : 100mA */

                     

                     

                        /* 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 */

                        0x00,                          /* Number of endpoints */

                        0xFF,                          /* Interface class */

                        0x00,                          /* Interface sub class */

                        0x00,                          /* Interface protocol code */

                        0x00,                          /* Interface descriptor string index */

                     

                     

                        /* Interface 0, Alt. Setting 1: ISO IN endpoint. */

                        0x09,                          /* Descriptor size */

                        CY_U3P_USB_INTRFC_DESCR,        /* Interface descriptor type */

                        0x00,                          /* Interface number */

                        0x01,                          /* Alternate setting number */

                        0x01,                          /* Number of endpoints */

                        0xFF,                          /* Interface class */

                        0x00,                          /* Interface sub class */

                        0x00,                          /* Interface protocol code */

                        0x00,                          /* Interface descriptor string index */

                     

                     

                        /* Endpoint descriptor for consumer 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 */

                        0x40,0x00,                      /* Max packet size = 64 bytes */

                        0x01                            /* Servicing interval for data transfers */

                    };

                     

                     

                    /* Standard language ID string descriptor */

                    const uint8_t CyFxUSBStringLangIDDscr[] __attribute__ ((aligned (32))) =

                    {

                        0x04,                          /* Descriptor size */

                        CY_U3P_USB_STRING_DESCR,        /* Device descriptor type */

                        0x09,0x04                      /* Language ID supported */

                    };

                     

                     

                    /* Standard manufacturer string descriptor */

                    const uint8_t CyFxUSBManufactureDscr[] __attribute__ ((aligned (32))) =

                    {

                        0x10,                          /* Descriptor size */

                        CY_U3P_USB_STRING_DESCR,        /* Device descriptor type */

                        'C',0x00,

                        'y',0x00,

                        'p',0x00,

                        'r',0x00,

                        'e',0x00,

                        's',0x00,

                        's',0x00

                    };

                     

                     

                    /* Standard product string descriptor */

                    const uint8_t CyFxUSBProductDscr[] __attribute__ ((aligned (32))) =

                    {

                        0x08,                          /* Descriptor size */

                        CY_U3P_USB_STRING_DESCR,        /* Device descriptor type */

                        'F',0x00,

                        'X',0x00,

                        '3',0x00

                    };

                     

                     

                    /* Place this buffer as the last buffer so that no other variable / code shares

                    * the same cache line. Do not add any other variables / arrays in this file.

                    * This will lead to variables sharing the same cache line. */

                    const uint8_t CyFxUsbDscrAlignBuffer[32] __attribute__ ((aligned (32)));

                     

                     

                    /* [ ] */

                    • 22. Re: Issues with isoc.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k], ref pktsInfo[k]))
                      HemanthR_06

                      Hi,

                       

                      There is no 'else' statement for:

                      if (isoc.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k], ref pktsInfo[k]))

                      Can you please use one more variable and check if the 'else' is executed at any point of time.

                       

                      Regards,

                      Hemanth

                      • 23. Re: Issues with isoc.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k], ref pktsInfo[k]))
                        maVa_1182686

                        there is a failures++ there...I can tell from the fact that failures is not increasing that I never go to that part of the code.

                         

                        When no data is ready the code still goes into if (isoc.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k], ref pktsInfo[k]))

                        but len = 0

                         

                        I test for that  doing

                          if (PacketLength > 0){

                         

                        }


                        I added code now that prints "empty pack" and depending on how much I throttle the FPGA that happens a lot or not.

                        This is the output for example of 8 packets per Xfer and a 2 bursts of 1024

                         

                        Console.WriteLine("test")

                        for (int i = 0; i < PacketLength / 2048; i++)  //8 packets per Xfer

                                                    {

                                                        a = (USBpacket[i * 1 * 2048]);  //scanning the data to see if every 1024 bytes there is an increment

                                                        Console.WriteLine((a / 2).ToString());   //devide the incremented data by 16 to remove increment of 16 and make it increment of 1

                         

                         

                                                    }

                         

                        As you can see...the testdata is not correct.******..(when xBuf == pkts all the time, the testdata is always ok 1,2,3,....)

                         

                         

                         

                         

                         

                        length xBuf=  16384

                        length pkts=  10240

                        k= 1

                        test:

                        7****

                        8*****

                        36*****

                        9*****

                        100*****

                        *************************

                         

                         

                        length xBuf=  16384

                        length pkts=  10240

                        k= 2

                        test:

                        12

                        40

                        13

                        14

                        42

                        *************************

                         

                         

                        length xBuf=  16384

                        length pkts=  10240

                        k= 3

                        test:

                        107

                        17

                        18

                        46

                        19

                        *************************

                         

                        These are the empty packages...

                        isoc.FinishDataXfer still returns TRUE...but len = 0

                        empty pack

                        *************************

                         

                         

                        empty pack

                        *************************

                         

                         

                        empty pack

                        *************************

                         

                         

                        empty pack

                        *************************

                         

                         

                        empty pack

                        *************************

                         

                         

                        empty pack

                        *************************

                         

                         

                        empty pack

                        *************************

                         

                         

                        empty pack

                        *************************

                         

                         

                        empty pack

                        *************************

                         

                         

                        empty pack

                        *************************

                         

                         

                        empty pack

                        *************************

                         

                         

                        empty pack

                        *************************

                         

                         

                        empty pack

                        *************************

                         

                         

                        empty pack

                        *************************

                         

                        In the next sequence the FPGA did have enough data ready so the xFer went OK

                         

                        length xBuf=  16384

                        length pkts=  16384

                        k= 2

                        test:

                        22

                        23

                        24

                        25

                        26

                        27

                        28

                        29

                        *************************

                         

                         

                        length xBuf=  16384

                        length pkts=  16384

                        k= 3

                        test:

                        30

                        31

                        32

                        33

                        34

                        35

                        36

                        37

                        *************************

                         

                         

                         

                        My complete relevant code ==

                         

                        for (; bRunning; )

                                    {

                                        nIteration++;

                                        // WaitForXfer

                                        unsafe

                                        {

                                            //fixed (byte* tmpOvlap = oLaps[k])

                                            {

                                                ovData = (CyUSB.OVERLAPPED)Marshal.PtrToStructure(handleOverlap[k].AddrOfPinnedObject(), typeof(CyUSB.OVERLAPPED));

                                                if (!EndPoint.WaitForXfer(ovData.hEvent, 500))

                                                {

                                                    EndPoint.Abort();

                                                    PInvoke.WaitForSingleObject(ovData.hEvent, 500);

                                                }

                                            }

                                        }

                         

                                        if (EndPoint.Attributes == 1)

                                        {

                                            CyIsocEndPoint isoc = EndPoint as CyIsocEndPoint;

                                            // FinishDataXfer

                                            if (isoc.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k], ref pktsInfo[k]))

                                            {

                                             

                                                PacketLength = len;

                         

                                                ISO_PKT_INFO[] pkts = pktsInfo[k];

                         

                                                for (int j = 0; j < PPX; j++)

                                                {

                                                    if (pkts[j].Status == 0)

                                                    {

                                                        XferBytes += pkts[j].Length;

                         

                                                        Successes++;

                                                    }

                                                    else

                                                        Failures++;

                         

                                                    pkts[j].Length = 0;

                                                }

                         

                         

                                                //if (PacketLength > 20480) { PacketLength = 20480; }

                                                //INTERMEADIATE = xBufs[k];

                                                USBpacket = xBufs[k];

                                                //for (int i = 0; i < PacketLength / 1024; i++)

                                                if (PacketLength > 0)

                         

                                                {

                                                    Console.WriteLine("length xBuf=  " + xBufs[k].Length.ToString());

                                                    Console.WriteLine("length pkts=  " + len.ToString());

                                                    Console.WriteLine("k= " + k.ToString());

                                                    Header_found = 0;

                                           

                                                    Index = 0;

                                              

                         

                                                    for (int i = 0; i < 1024 * 8; i++)

                                                    {

                                                        USBpacket_rearranged_ISO[i] = USBpacket[i];

                         

                         

                                                    }

                         

                                                    countertje += 1;

                                                    int a = 0;

                                                    //SendUdp(65432, "127.0.0.1", 65432, USBpacket_rearranged_ISO);

                                                    Console.WriteLine("test:");

                                                    //Console.WriteLine(USBpacket_rearranged_ISO[200].ToString());

                                                    for (int i = 0; i < PacketLength / 2048; i++)  //8 packets per Xfer

                                                    {

                                                        a = (USBpacket[i * 1 * 2048]);  //scanning the data to see if every 1024 bytes there is an increment

                                                        Console.WriteLine((a / 2).ToString());   //devide the incremented data by 16 to remove increment of 16 and make it increment of 1

                         

                                                    }

                                                    //Console.WriteLine(countertje.ToString());

                                                    //Thread.Sleep(1);

                         

                                                    double variable = 3;

                                                    for (int i = 0; i < blocktime; i++)

                                                    {

                         

                                                        variable = Math.Cosh(variable);

                                                    }

                         

                         

                         

                         

                                                }

                                                else

                                                {

                                                    Console.WriteLine("empty pack");

                                                  

                                                }

                                                Console.WriteLine("*************************");

                                                Console.WriteLine();

                         

                                             

                         

                         

                                            }

                                            else

                                                Failures++;

                        • 24. Re: Issues with isoc.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k], ref pktsInfo[k]))
                          maVa_1182686

                          BTW...I experimented a little with Thread.sleep(x) and a blocking routine to slow down the host.

                          That's what this was for.  

                            for (int i = 0; i < blocktime; i++)

                                                      {

                                                           variable = Math.Cosh(variable);

                                                      }

                          I was just stalling the cpu for an arbitrary time...

                           

                          You can do some flow control inn this way but only when you only allow 1 xFer to Queue which leads to other problems.

                           

                          Definely not a solution

                          • 25. Re: Issues with isoc.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k], ref pktsInfo[k]))
                            HemanthR_06

                            Hi,

                             

                            Please find the attachments.

                            1. In the attached project, CY_FX_ISO_PKTS = 1, CY_FX_ISO_BURST =4, DMA Buffer Size = 4KB, Number of DMA Buffers = 3.

                            1st packet (1024 byte) of 4KB buffer is filled with 0xAA, second with 0xAB, third 0xAC and fourth 0xAD. Other 2 DMA buffers are filled in the similar fashion.

                             

                            2. When a DMA Buffer is committed to USB Socket, the data locations - 0, 1024, 2048 and 3072 are incremented by 1. I mean: For the first DMA buffer committed, those locations will have 0, 1, 2 and 3. For the 2nd DMA Buffer committed the locations would be 4, 5, 6, 7.

                             

                            In the figure ZLP_starts.png, Transfer 32 is 3rd DMA buffer from the beginning of the test. So, you can see that the last packet of this DMA buffer has 0x0B as the first byte.

                             

                            In the same figure, in Transfer 33, you can see that FX3 has no data after the 3rd DMA buffer. So ZLP is being sent. I have made this as Time Stamp 0. In the figure Next_data_packet.png you can see that the next data comes in. And the data is as expected - first byte being 0x0C and the data being 0xAA. You can see that this data packet arrived after 436mS (so FX3 is not occupying full bandwidth it requested for).

                             

                            3. On the Host side, I start writing the first data byte of each 1024 packet into a file FinishData.bin. First_data_byte.png shows the screen shot of the same. The sequence is as expected.

                             

                            In another version of the Host App, I print the second byte of the 1024 byte packet too along with the first one. Also I write 0xCC followed by number of ZLPs occurred. (FYI: ZLPs occurred when 0xCC is seen in the file is the number followed by 0xCC * 256)

                            First_and_second_data_byte_along_with_zlp_count_after_0xCC.png shows the same. You can see that the underlined byte after k th packet is the content of that k th packet. (0xCC 0x0D indicates 0x0D * 256 ZLPs occurred - you can ignore this as of now).

                             

                            I am also attaching Form1.cs (Modified Streamer)

                             

                            Note:

                            1. If you want to use the file, you need to

                            Create a file FinishData.bin in the path that you mention in the attached file (Refer to /****************add path below***********/ in the file attached)

                            2. If you want to write the number of ZLPs into the file, then you need to uncomment the code in /****************modify if required***********/

                             

                            Regards,

                            Hemanth

                            • 26. Re: Issues with isoc.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k], ref pktsInfo[k]))
                              maVa_1182686

                              I will run the code and try to understand what you are doing. I will report back immediately. 

                              • 27. Re: Issues with isoc.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k], ref pktsInfo[k]))
                                maVa_1182686

                                Hi,

                                I've programmed my devkit with the .IMG from your code.

                                All transmissions I see are exactly the same size.

                                 

                                When I choose 8 packets per Xfer the packets are all 32kB (like you expect when you have no bottleneck)

                                The throughput of the transmission is +- 32MB/s if you have at least 2 Xfers in your Queue:

                                 

                                 

                                 

                                 

                                When I increase the Packets per Xfer the chunks seen in wireshark increase accordingly (16 Packets per Xfer):

                                 

                                 

                                The throughput does not increase though:

                                 

                                 

                                 

                                 

                                I think the rate at which you produce data is too fast to encounter my problem!

                                The Data producer is held back by the maximum speed you are able to attain with the settings chosen ( CY_FX_ISO_PKTS = 1, CY_FX_ISO_BURST =4, DMA Buffer Size = 4KB )

                                 

                                Indeed every 125uS a packet of size 4KB can be transmitted which is 8 times per mS and thus 4kB*8/mS =>  32MB/s

                                 

                                Your data "producer" is therefor still bottle necked by the USB busd and you do not encounter my problem. All transmissions are completely "filled" and "len" is always equal to size of xBuf[k]

                                 

                                My problem only occurs when you produce LESS then the maximum attainable speed at the chosen settings.

                                 

                                For example, in my application i want to transmit at 9.6MB/s (I have applications which require much more but that's beside the point) and that is the amount of data my FPGA produces.

                                 

                                When I use your settings ( CY_FX_ISO_PKTS = 1, CY_FX_ISO_BURST =4, DMA Buffer Size = 4KB ) the throughput will be comprised of

                                - correct packets where len = size of xBuf[k] (32kB in this case)   <= no problem

                                - empty packets where len = 0   <= no problem

                                - half packets where len =! 0 and < size of xBuf[k]   <= PROBLEM

                                • 28. Re: Issues with isoc.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k], ref pktsInfo[k]))
                                  HemanthR_06

                                  Hi,

                                   

                                  I think you have chosen ISOC OUT Endpoint instead of IN. Please check.

                                   

                                  Regards,

                                  Hemanth

                                  • 29. Re: Issues with isoc.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k], ref pktsInfo[k]))
                                    maVa_1182686

                                    ow...silly me...I'm not used to still have an OUT and IN so I didn't notice, sorry for that!

                                     

                                    I choose the right one now but all i;m seeing is this:

                                     

                                    Is that correct?