how to transfer large files with fx2lp

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

cross mob
Anonymous
Not applicable

Hi there,

   

 

   

I am trying to transfer large files(larger than 1MB) with fx2lp.  Actually, I just followed AN61345(Implementing an FX2LP™-FPGA Interface). It worked well on EZ-USB console, 512 bytes send to ep2, 512 bytes back to ep6.

   

 

   

Then I made a app with VC6. Divide the large file to 512 bytes packets, and transfer them via Xferdata() fuction. The code is

   

 

   

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

   

 

   

{

   

for(j=0;j<buf_size;j++){usb_i=sig_i[buf_size*i+j];}

   

if(USBDevice->BulkOutEndPt)

   

i_finish=USBDevice->BulkOutEndPt->XferData(usb_i,buf_size);

   

if(USBDevice->BulkInEndPt)

   

o_finish=USBDevice->BulkInEndPt->XferData(usb_o,buf_size);

   

for(j=0;j<buf_size;j++) {sig_o[buf_size*i+j]=usb_o;}

   

}

   

 

   

When the files are small(<20kB), it works well. Every step ep6 become empty when the data is read by host.

   

 

   

If the file is larger, as the process continus, ep6 will not be empty sometime and all the followed data is error code(always CD).

   

 

   

I am using cy3684_kit_15, hope someone help me to find the reason or give some advice.

   

 

   

Thanks!

0 Likes
4 Replies
Anonymous
Not applicable

  Hi,

   

  Please take the trace of USB traffic(using USB traffic analyzers like CATC) and post it here so that we can have a look at it.

   

Thanks

   

Prajith

   


0 Likes
Anonymous
Not applicable

 Hi,

   

Thanks for your reply. Besides, what's a CATC? An instrument or some kind of software?

   

I just made a simple test:

   

 

   

LONG buf_size=512;

   

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

   

{

   

o_finish=USBDevice->BulkOutEndPt->XferData(usb_i,buf_size);

   

i_finish=USBDevice->BulkInEndPt->XferData(usb_o,buf_size);

   

cout<<o_finish<<'\t'<<i_finish<<endl;

   

}

   

The output:

   

1 1

   

1 1

   

...

   

1 1

   

1 0

   

1 0

   

...

   

1 0

   

press any key...

   

 

   

The BulkIn XferData immediately failed. I think there are two possible reasons: (a)EP6 stalled; (b)EP6 do not have enough data. Is it right?

   

Then after the test above, I just do

   

i_finish=USBDevice->BulkInEndPt->XferData(usb_o,buf_size);

   

again. And it returns 1, the empty flag also changed.

   

So, can I say EP6 works well, the XferData() goes wrong?

   

I am try to start two new threads for BulkIn, one failed, start another, hope it worked.

   

 

   

Thanks again!

0 Likes
Anonymous
Not applicable

 Sorry guys,

   

I just changed a powersupply, and the problem solved...

   

Should find this at the very start...

   
        
0 Likes
Anonymous
Not applicable

 Coool  

   

Thanks for sharing the fix.

0 Likes