XferData() doesn't return when data arrives during wait

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

cross mob
WGT_4383351
Level 5
Level 5
First like received

Set the TimeOut to 10 seconds. Then use XferData() to read 2KB data from an IN endpoint, then the wait begain since there is no data available.

Then 2KB data arrived, but XferData() won't return until time out and fail. Then the next XferData() call will get the 2KB data successfully.

Why does this happen? Shouldn't XferData() return true immediately during wait when the data arrive? Does this behavior depend on some properties of CyBulkEndPoint, or depend on the firmware?

0 Likes
1 Solution
YiZ_31
Moderator
Moderator
Moderator
1000 replies posted 750 replies posted 500 replies posted

Hi,

You can call CyU3PUsbLPMDisable() here to prevent FX3 enter low power state. That would make things work.

pastedImage_0.png

Regards,
Eddie

View solution in original post

19 Replies
WGT_4383351
Level 5
Level 5
First like received

The firmware used is AN87216's AutoSlave.img.

0 Likes
YiZ_31
Moderator
Moderator
Moderator
1000 replies posted 750 replies posted 500 replies posted

Hi,

May I know how did you set the time out?

Regards,
Eddie

0 Likes
WGT_4383351
Level 5
Level 5
First like received

CyBulkEndPoint inEndpoint;

inEndpoint.TimeOut = 10*1000;

0 Likes
WGT_4383351
Level 5
Level 5
First like received

Now I have tested with Control center too, same result.

Test method:

(1) Load master and slave firmware to board

(2) Open two control center

(3) Click transfer data in button for slave in one control center to receive 1KB data, it will be blocked since there is no data and will time out soon

(4) Quickly (before slave time out) get to another control center and press transfer data out button for master twice to send 2*1KB data to master. (Why twice - this is another problem, if you only send 1*1KB, the slave will always timeout. But this have nothing to do with this question, just send 2*1KB - or 1*2KB)

(5)Switch back to the first control center and wait for the time out(unexpected as described). Then press data in button for slave twice, both 1KB will be received succesfully.

0 Likes
WGT_4383351
Level 5
Level 5
First like received

This doesn't make sense, did you mean what ever the time out is, and whether enough data have arrived during wait, XferData will always fail with zero data if there is no data when XferData is called?

For exampe, did you mean:

(1) set time out to 10 sec

(2) use XferData to receive 1KB data at 0 sec and blocked

(3) transfer 1KB data to that device at 1 sec

(4) XferData time out /faile with zero data at 10sec?

The expected behavior is XferData success at 1 sec with 1KB data returned, since 1KB data arrive at 1 sec.

0 Likes
YiZ_31
Moderator
Moderator
Moderator
1000 replies posted 750 replies posted 500 replies posted

Hi,

Sorry my former reply was incorrect. Actually I did the test you mention with two USB control center window. The firmware I uesed is USBBulkLoopAutoEnum. If I press Transfer Data-in on the left first and then the Transfer Data-out on the right fast enough, the left window can get the data without error. So I guess you problem is still the timing parameter issue, try to extend the TimeOut value and see if there are any improvement.

pastedImage_0.png

0 Likes
WGT_4383351
Level 5
Level 5
First like received

Where are the bulk loop firmwares? Can't find them in C:\Program Files (x86)\Cypress

0 Likes
WGT_4383351
Level 5
Level 5
First like received

Found it , C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\firmware\basic_examples

0 Likes
WGT_4383351
Level 5
Level 5
First like received

Confirmed, but what is the difference between Master/Slave and bulkloop firmware to make this difference? They both use hardware manager buffer queue, should not have difference between IO read behavior.

0 Likes
WGT_4383351
Level 5
Level 5
First like received

Or how to debug and find out what cause this behavior with Master/Slave FW and stacked CYUSB3KIT-003? Do you have stacked CYUSB3KIT-003 in hand to test?

0 Likes
WGT_4383351
Level 5
Level 5
First like received

Can you verify the behavior with stacked FX3 board? The reason that bulkloop works may be the DMA is U2U, not P2U.

0 Likes
WGT_4383351
Level 5
Level 5
First like received

Also check last posts this thread AN87216 buffer mechanism 

0 Likes
YiZ_31
Moderator
Moderator
Moderator
1000 replies posted 750 replies posted 500 replies posted

I got several CYUSB3KIT-003 but I could not find the connector. But I think with USBBulkLoop example we have confirmed that the TimeOut parameter in host side is vaild. XferData() actually can return when data arrives during wait no matter what the FX3 application is. The data loop in AN87216 may took more time delay which caused the XferData timeout.

0 Likes
WGT_4383351
Level 5
Level 5
First like received

The environment is different. With USBBulkLoop the DMA is U2U, not P2U, maybe it is this difference that cause the problem. You can order the connector. As a setup in some AN, its normal to stock some such parts.

0 Likes
WGT_4383351
Level 5
Level 5
First like received

You can also use some fly wire to connecte the boards. No need to connect data bus, just enable pull up/pull down resistors on IO pad.

0 Likes
YiZ_31
Moderator
Moderator
Moderator
1000 replies posted 750 replies posted 500 replies posted

Hi,

You can call CyU3PUsbLPMDisable() here to prevent FX3 enter low power state. That would make things work.

pastedImage_0.png

Regards,
Eddie

Now I tested the configuration with two Streamer.exe the speed finally get fast, but the process stall after several seconds. The method is start one Streamer to receive on slave, then start another Streamer to send on master.

0 Likes
WGT_4383351
Level 5
Level 5
First like received

This works! Did you find out that by guess and try or a debug session of the framework?

0 Likes
YiZ_31
Moderator
Moderator
Moderator
1000 replies posted 750 replies posted 500 replies posted

My colleagure debug this issue with USB analyszer and found FX3 did not send EDRY which make the Xfer fail. But bulkloop example sends ERDY.

0 Likes