FX2LP pauses for 125us during GPIF In Transfers

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
RoWa_685396
Level 1
Level 1

I'm using the FX2LP to read in info from an external FPGA which is mimicking a cameralink interface. I've got it working about 50% of the time but have an issue where the GPIF transfers will stop for 125us while something else is going on (not sure what but the USB micro frames are 125us and this may be a clue). I'm trying to load 1024 16 bit Words into the EP2InFIFO's from the FPGA. Below is a code snipet of the routine which starts the GPIF Burst Read routine. Right now I'm polling for it to be done and then arming the endpoint. This routine would be called 4 times to load the entire 4K bytes of data.  I've enabled a GPIF Crtl output line that I can monitor on the scope to see when its loading the FIFO and then have Port A1 pin toggling while in this routine to help me debug what is going on.

The issue is that I'm missing data that is coming from the FPGA. The FPGA is producing data at a relatively slow 1MHz rate. I've got the GPIF configured to read data in when the DataValid signal is high. From the attached scope pic this works most of the time (the green boxes). The issue is that it seems like the GPIF transfer process will hang randomly for 125us and then resume. From a code standpoint, since the PA1 pin is still toggling at the same rate the CPU is still in the routine below waiting for the FIFO to fill, however during this 125us period (the red boxes in the pic) its missing data. Any clue what may be causing the GPIF transfer to hang for 125us?

I've used similar routine like this before on other project and they all worked however in those cases the reads were at a much faster rate. Any help is appreciated.

BYTE Send_EP2_wordsBurst (WORD NumOfWords  )

{

BYTE a;

if ( WaitForEp_Full ( bmEP2FULL ))

return FALSE;

       EP2GPIFTCH = NumOfWords  >> 8;  //(GPIFTCB0) setup transaction count

       SYNCDELAY;                

       EP2GPIFTCL = NumOfWords  & 0xff;

       SYNCDELAY;             

       if( !( EP2468STAT & bmEP2FULL ) )

          {

          a=EP2GPIFTRIG;          // trigger start of  read process

          while( !( GPIFTRIG & 0x80 ) ) // Poll GPIFTRIG.7 Done bit

               {

               IOA ^= 0x02;          //toggle pin to see whats going on

               }

          GPIFTRIG = GPIFTRIGRD | GPIF_EP2; // R/W=1, EP[1:0]=FIFO_EpNum for EPx read(s)

          }

     NumOfWords  *= 2 ; // convert to bytes

     EP2BCH = NumOfWords >> 8;      // load byte count to lock in packet

     SYNCDELAY;

     EP2BCL = NumOfWords & 0xff;

     SYNCDELAY;

return TRUE;

}

0 Likes
1 Solution

Hello,

Can you please try the following code snippet in your function-

      EP2GPIFTCH = NumOfWords  >> 8;

      SYNCDELAY;               

      EP2GPIFTCL = NumOfWords  & 0xff;

      SYNCDELAY;           

     if ( GPIFTRIG & 0x80 )            

     {

            if ( !( EP24FIFOFLGS & EP2FULL ) )      

            {

             GPIFTRIG = GPIFTRIGRD | GPIF_EP2;

             SYNCDELAY;

      

             while( !( GPIFTRIG & 0x80 ) )  

             {

               IOA ^= 0x02;

             }

              NumOfWords  *= 2 ;

              EP2BCH = NumOfWords >> 8;     

              SYNCDELAY;

              EP2BCL = NumOfWords & 0xff;

              SYNCDELAY;

          }

     }

Please let us know if it works for you. We've tested this in on our end but kept the slave flags always asserted so that the device could read data whenever an IN request is initiated from the host.

Best Regards,

Sananya

View solution in original post

0 Likes
4 Replies
Sananya_14
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hello,

-Could you please explain why a read is initiated from EP2GPIFTRIG register, and after polling, from the GPIFTRIG register?

-Could you kindly try reading in AUTO mode and check if data is still missing?

-Please attach your GPIF Designer waveform for us to reproduce the issue on our end.

Best Regards,

Sananya

0 Likes
lock attach
Attachments are accessible only for community members.

The read is done from the EP2GPIFTRIG to start an IN transfer into EP2 through the GPIF. I then poll the GPIFTRIG.7 DONE flag to see when the transfer is done.

In AUTOIN mode the problem still exists--the GPIF seems to stall for 125us while something else is going on.

Attached is the gpif.c code. I'm using the burst_r waveform.

0 Likes
lock attach
Attachments are accessible only for community members.

In the previous replay I attached a gpif.c which did not correspond to the waveform fro the original post. Attached is the one that coresponds to the scope pic, where it waits for DVAL to go high to clock in the data on the databus.

Also, while the GPIF is running I've tried disabling the interrupts (using EA=0 and EZUSB_IRQ_DISABLE()) and that does not effect the problem.

0 Likes

Hello,

Can you please try the following code snippet in your function-

      EP2GPIFTCH = NumOfWords  >> 8;

      SYNCDELAY;               

      EP2GPIFTCL = NumOfWords  & 0xff;

      SYNCDELAY;           

     if ( GPIFTRIG & 0x80 )            

     {

            if ( !( EP24FIFOFLGS & EP2FULL ) )      

            {

             GPIFTRIG = GPIFTRIGRD | GPIF_EP2;

             SYNCDELAY;

      

             while( !( GPIFTRIG & 0x80 ) )  

             {

               IOA ^= 0x02;

             }

              NumOfWords  *= 2 ;

              EP2BCH = NumOfWords >> 8;     

              SYNCDELAY;

              EP2BCL = NumOfWords & 0xff;

              SYNCDELAY;

          }

     }

Please let us know if it works for you. We've tested this in on our end but kept the slave flags always asserted so that the device could read data whenever an IN request is initiated from the host.

Best Regards,

Sananya

0 Likes