cancel
Showing results for 
Search instead for 
Did you mean: 

USB Superspeed Peripherals

user_2585021
New Contributor II

I have a question about Bulk Out transfer.


Currently I am using Bulk Out transfer to stream data into our logic.

The data to be sent is 0x80100 bytes for each Bulk Out transfer.


The source code of the application is shown below.


int MyXferBulkOut(unsigned char *dt, int length)
{

CCyUSBDevice *USBDevice;
CCyUSBEndPoint *OutEndpt;
bool success;
ULONG ret;
int instance;


USBDevice = s_USBDevice; // USB Device Object, when we are get on initialization.

OutEndpt = USBDevice->EndPointOf(0x02); // BulkOut EP2, Auto DMA, Buffer Count = 4
if (OutEndpt == NULL) {
return(-1);
}

OutEndpt->TimeOut = 5000;
success = OutEndpt->XferData( dt, length ); // length = 0x80100;

if (success) {
ret = 0;
}
else{
ret = -1;
}

return ret;
}

 


I have some problem.

After executing 0x80 100byte Bulk Out transfer with the XferData function in the above source code, immediately after the function returns
Bulk Out transfer the next 0x80 100byte data.

At this time, the length of data transmitted to our logic circuit is often shorter than expected.

The cause is completely from the EndPoint Buffer of EP2 to our logic circuit immediately after the XferData function returns.
Since it has not been flushed and the XferData function is called again in the above source code in that state,
This is because the previous data remains in the End Point Buffer of EP2 and the next Bulk Out transfer is instructed.
I'm guessing.

I have a few questions.

Q1. Is there any data left in the Endpoint Buffer immediately after the XferData function (BulkOut) returns?

Or does calling the XferData function transfer to EP2-> EP2's Buffer is completely flushed before returning?

Q2. If there is any data left in the EP2 Endpoint Buffer when the XferData function (BulkOut) returns, that is
How to check if it is empty?

Best regards.

0 Likes
3 Replies
Rashi_Vatsa
Moderator
Moderator

Hello,

At this time, the length of data transmitted to our logic circuit is often shorter than expected.

>>From this I understand that, for the second transfer the data is not sent completely.

>>Please confirm if the first transfer was success and the data received on the device was as expected

This is because the previous data remains in the End Point Buffer of EP2 and the next Bulk Out transfer is instructed.

>> Can you please let me know which library are you using in your host application - CyAPI (C++) CYUSB.NET (C#). This will help me to check the appropriate source code of the API.

>>Please let me now the return value of XferData API when the data transferred is shorter than expected.

Edited:

>>Please let me know length of  data returned by XferData for second transfer

Regards,
Rashi
0 Likes
user_2585021
New Contributor II

Hi Rashi,

Thank you for the reply.

>>At this time, the length of data transmitted to our logic circuit is often shorter than expected.

>>From this I understand that, for the second transfer the data is not sent completely.

>>Please confirm if the first transfer was success and the data received on the device was as expected

>>This is because the previous data remains in the End Point Buffer of EP2 and the next Bulk Out transfer is instructed.

The above is the same for me.
As soon as the Bulk Out porting from your PC to EP2 is complete, you will be able to Bulk Out porting to EP2.
After a short wait for each port, you can send the expected data out of FX3.

However, there is a very low probability that the expected number of data will be shorter than expected by initiating EP2 porting before sending it out.

>> Can you please let me know which library are you using in your host application - CyAPI (C++) CYUSB.NET (C#). This will help me to check the appropriate source code of the API.

Ans. Details of using CyAPI (C ++). The SDK is 1.3.4.

>>Please let me now the return value of XferData API when the data transferred is shorter than expected.

Ans. TRUE is returned even if the data is shorter than expected.I think the porting to EP2 is because it is complete.

Edited:

>>Please let me know length of data returned by XferData for second transfer

ans. It will always be 0x80100byte after the second transfer. Porting to EP2 will never fail.

=====

I thought about the following method.

When the EP2 DMA buffer Flush (CyU3PUsbFlushEp) is executed inside FX3 after the transfer to EP2 is completed,
Will this function return after Flush is complete? (Synchronous functuon?)

If it is Synchronous functuon, can the next bulk transfer be executed after calling Flush from FX3 FW?

It would be helpful if you could give me some advice on how to do this.

best regards,

KK

0 Likes
Rashi_Vatsa
Moderator
Moderator

Hello,

However, there is a very low probability that the expected number of data will be shorter than expected by initiating EP2 porting before sending it out.

>> By this you mean that the issue is seen very rarely. Is that correct?

Ans. TRUE is returned even if the data is shorter than expected. I think the porting to EP2 is because it is complete

>> Can you please share the USB traces using Wireshark (.pcap file) . This will help us to understand the issue better.

/if you have a hardware analyzer like Lecroy you can capture the USB traces using that or else you can use software analyzer like Wireshark

It will always be 0x80100byte after the second transfer. Porting to EP2 will never fail.

>> Please track the producer and consumer events on the firmware side just to confirm if the DMA buffers are available to get the data sent from host.

Please let me know the BULK OUT endpoint size (EP 02 size) and the  FX3 SDK version used.

Regards,
Rashi
0 Likes