USB reading/writing 0 bytes

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

cross mob
Anonymous
Not applicable

 Hi,

   

I am using FX2 controller on a fpga board with CyUSB driver and trying to get data from the fpga using Visual C++2010.

   

I did program the fpga with an application that came with that fpga board successfully using verilog HDL. Then using C++ I checked all configurations and endpoints and they looked correct. This is my code in short:

   

I chose Interface[1] which showed 6 bulk end points. 

   

CCyUSBDevice *USBDevice = new CCyUSBDevice(NULL, GUID_KNJN_FX2);

   

USBDevice->Open(d);

   

CCyUSBConfig cfg =USBDevice->GetUSBConfig(0);

   

CCyUSBInterface *ifc =cfg.Interfaces[1];

   

CCyUSBEndPoint *BulkOutPipe0=ifc->EndPoints[1];//defined other endpoints similarly

   

unsigned char buf='A';long len=1;

   

now when I use XferData(&buf,len) with any bulkoutpipe, I get len=0. For read operation the buffer is returned empty with len=0; 

   

1. I tried changing Bulkpipe->Timeout values but I get above immediately without any wait time.

   

2. I tried modifying the HDL state machine. It will wait for any character and then send values. Above I tried to write and then read but it did not work. Even when I configure fpga to send data continuously, I dont get any value using Xferdata read. 

   

3. I get usbdstatus success and ntstatus 0 during both reading and writing. 

   

Am I missing something here? Do I need to set configuration of some other endpoint before using Xferdata()? If I get no error any idea what can be happening? I don't see anything wrong in the hdl code as well. I am hesitant to try begindataxfer() method.

   

Please let me know anything that can be done to solve this issue. 

   

Thanks,

   

Skay

0 Likes
5 Replies
Anonymous
Not applicable

 Sorry for bad formatting. There seems no way to edit now.

0 Likes
Anonymous
Not applicable

 Hi,

   

 

   

Can you share the schematics,FX2Lp project and VHDL code?

   

 

   

Regards,

   

Vikas.

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

 Hi,

   

 

   

Thanks a lot for your reply.

   

 

   

The board is xylo-EM   ->  http://www.knjn.com/docs/KNJN%20FX2%20FPGA%20boards.pdf

   

 

   

I tried simplest possible code of blinking LED's on that board when there is a data on the USB buffer. Verilog code is attached. I found out that the FIFO_empty buffer signal is always logic zero as LEd's (v file) always blink.

   

 

   

I also used USB sniffer softwares and found out that only device and control descriptors packets are transferred. I did not see any bulk data packet. I also tested this on other working boards, but got stuck the same way.

   

 

   

C++ code

   

 

   

void main()

   

{

   

CCyUSBDevice *USBDevice = new CCyUSBDevice(NULL, GUID_KNJN_FX2);

   

int devices = USBDevice->DeviceCount();

   

USHORT vID, pID;int d = 0;

   

do{USBDevice->Open(d);vID = USBDevice->VendorID;pID = USBDevice->ProductID;d++;} while(d < devices );

   

CCyUSBConfig cfg =USBDevice->GetUSBConfig(0);

   

CCyUSBInterface *ifc =cfg.Interfaces[1];

   

CCyUSBEndPoint *BulkOutPipe0=ifc->EndPoints[1];

   

CCyUSBEndPoint *BulkInPipe1=ifc->EndPoints[2];

   

CCyUSBEndPoint *BulkOutPipe2=ifc->EndPoints[3];

   

CCyUSBEndPoint *BulkOutPipe3=ifc->EndPoints[4];

   

CCyUSBEndPoint *BulkInPipe4=ifc->EndPoints[5];

   

CCyUSBEndPoint *BulkInPipe5=ifc->EndPoints[6];

   

printf("Blindink the LED(s) for a few seconds... ");

   

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

   

{

   

LONG len = 1;

   

BulkOutPipe2->XferData((PUCHAR)&i, len); // send one byte (the value of i) to FIFO2

   

Sleep(50);

   

}

   

delete USBDevice;

   

printf("done - press a key to terminate");

   

_getch();

   

}

   

 

   

Let me know what do you think. Thanks a lot!

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

 I am facing the same problem. Did you happen to figure out a solution?

   

Any help would be great.

   

Thanks!

   

Abinaya

0 Likes
Anonymous
Not applicable

In the inf file, I commented the lines in [CYUSB.AddReg.Guid] section and line "CYUSB.GUID= " in [Strings] section to get rid of this very annoying problem.

0 Likes