3 Replies Latest reply on Oct 29, 2018 7:01 PM by YangyangC_06

    the 'AN65974' sources(SlaveFifoSync and fpga_slavefifo2b_verilog): the datas will be lost

      I build the 'AN65974' sources(SlaveFifoSync and fpga_slavefifo2b_verilog) and upgrade the broad to do the streamIN test.

      But I found that some data will be lost.I modify the app's source and check the DWORD value for usb datas.

      I found the number of the lost packet is every 4096 times.

      So I modify the source named 'slaveFIFO2b_streamIN.v':

      assign slwr_streamIN_ = ((current_stream_in_state == stream_in_write) | (current_stream_in_state == stream_in_write_wr_delay)) ? 1'b0 : 1'b1;

      to

      assign slwr_streamIN_ = (current_stream_in_state == stream_in_write) ? 1'b0 : 1'b1;

      the result the 4096 times packet is not lost.But when the fast the data is passing from fpga to the pc,the data is still lost in some times.I read the doc to find the way.The doc says the flag_b is for the full flag.I think if the full flag can move up when the remaining number of the last buffer is the 256 bytes.the fpga can advance stopping the datas sent to FX3.But I do not  know how to do this?

        • 1. Re: the 'AN65974' sources(SlaveFifoSync and fpga_slavefifo2b_verilog): the datas will be lost
          YangyangC_06

          Hi Ru feng,

           

          Which application are you using when you say but I found that some data will be lost.I modify the app's source and check the DWORD value for usb datas.

          • 2. Re: the 'AN65974' sources(SlaveFifoSync and fpga_slavefifo2b_verilog): the datas will be lost

            Hi yyca,

            In the directory:

            EZ-USB FX3 SDK\1.3\application\cpp\streamer\

            To Modify the file:

            Streamer.h

            To function:

            static void XferLoop().

            The fpga module 'slaveFIFO2b_streamIN.v' will send the dword value from 0 to 0xffffffff.

            So I write the codes in the app's function to check the Streamer in datas.

            sources:

                  static void XferLoop()

                    {

                        long BytesXferred = 0;

                        unsigned long Successes = 0;

                        unsigned long Failures = 0;

                        int i = 0;

             

             

                        // Allocate the arrays needed for queueing

                        PUCHAR *buffers = new PUCHAR[QueueSize];

                        CCyIsoPktInfo **isoPktInfos = new CCyIsoPktInfo*[QueueSize];

                        PUCHAR *contexts = new PUCHAR[QueueSize];

            //........................................................................................................................................................................................

            unsigned long* rLen_q = new unsigned long[QueueSize];

                        OVERLAPPED inOvLap[MAX_QUEUE_SZ];

             

             

                        long len = EndPt->MaxPktSize * PPX; // Each xfer request will get PPX isoc packets

             

             

                        EndPt->SetXferSize(len);

             

             

                        // Allocate all the buffers for the queues

                        for (i=0; i< QueueSize; i++)

                        {

                            buffers[i]        = new UCHAR[len];

                            isoPktInfos[i]    = new CCyIsoPktInfo[PPX];

                            inOvLap[i].hEvent = CreateEvent(NULL, false, false, NULL);

             

             

                            memset(buffers[i],0xEF,len);

                        }

             

             

                        DateTime t1 = DateTime::Now; // For calculating xfer rate

             

             

                        // Queue-up the first batch of transfer requests

                        for (i=0; i< QueueSize; i++)

                        {

                            contexts[i] = EndPt->BeginDataXfer(buffers[i], len, &inOvLap[i]);

                            if (EndPt->NtStatus || EndPt->UsbdStatus) // BeginDataXfer failed

                            {

                                Display(String::Concat("Xfer request rejected. NTSTATUS = ",EndPt->NtStatus.ToString("x")));

                                AbortXferLoop(i+1, buffers,isoPktInfos,contexts,inOvLap);

                                return;

                            }

                        }

             

             

                        i=0;

             

             

                        // The infinite xfer loop.

                        for (;bStreaming;)

                        {

                            long rLen = len; // Reset this each time through because

                            // FinishDataXfer may modify it

             

             

                            if (!EndPt->WaitForXfer(&inOvLap[i], TimeOut))

                            {

                                EndPt->Abort();

                                if (EndPt->LastError == ERROR_IO_PENDING)

                                    WaitForSingleObject(inOvLap[i].hEvent,2000);

                            }

             

             

                            if (EndPt->Attributes == 1) // ISOC Endpoint

                            {

                                if (EndPt->FinishDataXfer(buffers[i], rLen, &inOvLap[i], contexts[i], isoPktInfos[i]))

                                {

                                    CCyIsoPktInfo *pkts = isoPktInfos[i];

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

                                    {

            if ((pkts[j].Status == 0) && (pkts[j].Length<=EndPt->MaxPktSize))

                                        {

                                            BytesXferred += pkts[j].Length;

             

             

                                            if (bShowData)

                                                Display16Bytes(buffers[i]);

             

             

                                            Successes++;

                                        }

                                        else

                                            Failures++;

             

             

                                        pkts[j].Length = 0; // Reset to zero for re-use.

            pkts[j].Status = 0;

                                    }

             

             

                                }

                                else

                                    Failures++;

             

             

                            }

             

             

                            else // BULK Endpoint

                            {

                                if (EndPt->FinishDataXfer(buffers[i], rLen, &inOvLap[i], contexts[i]))

                                {

                                    Successes++;

                                    BytesXferred += rLen;

            //........................................................................................................................................................................................

            rLen_q[i] = rLen;

                                    if (bShowData)

                                        Display16Bytes(buffers[i]);

                                }

                                else

                                    Failures++;

                            }

             

             

             

             

                            if (BytesXferred < 0) // Rollover - reset counters

                            {

                                BytesXferred = 0;

                                t1 = DateTime::Now;

                            }

             

             

                            // Re-submit this queue element to keep the queue full

                            contexts[i] = EndPt->BeginDataXfer(buffers[i], len, &inOvLap[i]);

                            if (EndPt->NtStatus || EndPt->UsbdStatus) // BeginDataXfer failed

                            {

                                Display(String::Concat("Xfer request rejected. NTSTATUS = ",EndPt->NtStatus.ToString("x")));

                                AbortXferLoop(QueueSize,buffers,isoPktInfos,contexts,inOvLap);

                                return;

                            }

             

             

                            i++;

             

             

                            if (i == QueueSize) //Only update the display once each time through the Queue

                            {

            //Check datas Start...............................................................................................................................................................

            unsigned long v_s = 0;

            int j;

            FILE* fp;

            if(rLen_q[0]>4)

            {

            fp = fopen("c:\\out.txt","ab");

            if(fp!=NULL)

            {

            v_s = *((unsigned long*)buffers[0]);

            for(i=0;i<QueueSize;i++)

            {

            for(j=0;j<(rLen_q[i]/sizeof(unsigned long));j++,v_s++)

            {

            if(((unsigned long*)buffers[i])[j]!=v_s)

            {

            fprintf(fp,"%08x!=%08x\r\n",((unsigned long*)buffers[i])[j],v_s);

            }

            }

            }

            fclose(fp);

            }

            }

            //Check datas Ends...............................................................................................................................................................

                                i=0;

                                ShowStats(t1, BytesXferred, Successes, Failures);

                            }

             

             

                        }  // End of the infinite loop

             

             

                        // Memory clean-up

                        AbortXferLoop(QueueSize,buffers,isoPktInfos,contexts,inOvLap);

                    }

             

            • 3. Re: the 'AN65974' sources(SlaveFifoSync and fpga_slavefifo2b_verilog): the datas will be lost
              YangyangC_06

              Hi

               

              Plese don't modify the FPGA source code which will lead to error condition. As you can check from AN65974, if you change .v file in that way, the time sequence will be different from what FX3 requires.

              We don't hear about the data loss problem. Could you please clarify the detailed information about your question?

              What's your hardware design? What's the steps you find this issue?