Hi, every one.
I'm using CY7C68013 to implement a data acquisition system.FPGA sends the data flow to the host via USB.The configuration of the USB is as follows: EP2 IN, 512bit, quad buffers, slave fifo, auto in mode, and with an external IFCLK(24Mhz).The writting rate to endpoint is about 2.5MB/s.And the FPGA writes to the endpoint2 continuously unless it is not full.
The host program is based on .NET(C#) .To test transfer speed, i ordered my host to request for data repeat from 68013. The XferSize was set to 256KB,and the host requested for 256KB each time.But the host program occasionally broke down.It can happened during the anytime when executing Xferdata()(maybe the first time or even after 10 mins). The return NtStatus can be "0xC000 0120" or "0xC001 0000".And the string returned by UsbStatusString() was "[state=HALTED status=UNKNOWN]".
I don't know how to map these error codes to the real problems.It seems others seldom using .NET to implement a project. I checked my FPGA program,the firmware and the C# program.But i can't find anything wrong.Maybe I've missed or misunderstood something.Please help me.
Main part of the firmware and C# codes are as follows:
Firmware:
void TD_Init(void) // Called once at startup
{
IFCONFIG |= 0x03; //external clock from FPGA:24 Mhz
SYNCDELAY;
REVCTL = 0x03; //
SYNCDELAY;
EP2CFG = 0xE0; // IN, bulk mode,quad buffering,512bit each buffer
SYNCDELAY;
FIFORESET = 0x80; // reset all FIFO
SYNCDELAY;
FIFORESET = 0x82;
SYNCDELAY;
FIFORESET = 0x84;
SYNCDELAY;
FIFORESET = 0x86;
SYNCDELAY;
FIFORESET = 0x88;
SYNCDELAY;
FIFORESET = 0x00;
SYNCDELAY;
EP2FIFOCFG = 0x09;
SYNCDELAY;
PINFLAGSAB = 0x00; // defines FLAGA as prog-level flag, pointed to by FIFOADR[1:0]
SYNCDELAY; PINFLAGSCD = 0x00; // FLAGC as empty flag, as pointed to by FIFOADR[1:0]
PORTACFG = 0x40; // Enable SLCS
SYNCDELAY;
FIFOPINPOLAR = 0x00; // set all slave FIFO interface pins as active low
SYNCDELAY;
EP2AUTOINLENH = 0x02; // autoin length:512bit
SYNCDELAY;
EP2AUTOINLENL = 0x00;
SYNCDELAY;
EP2FIFOPFH = 0x90;// FLAGA: PKTSTAT = 0,PF asserts if committed packest are more than 2.
SYNCDELAY;
EP2FIFOPFL = 0x00;
}
C# code
int count = 0;
CyBulkEndPoint bulkEndptOut;
private void button1_Click(object sender, EventArgs e)
{
USBDeviceList usbDevices = new USBDeviceList(CyConst.DEVICES_CYUSB);
CyUSBDevice MyDevice = usbDevices[0x04B4, 0x1004] as CyUSBDevice;
if (MyDevice == null)
{
MessageBox.Show("No device attached!");
return;
}
bulkEndptOut = MyDevice.EndPoints[1] as CyBulkEndPoint;
if (bulkEndptOut == null)
{
MessageBox.Show("Can't find endpoint!");
return;
}
bulkEndptOut.XferSize = 4096 * 64 ;// Set XferSzie 256KB
Thread t = new Thread(new ThreadStart(subFun));
t.Start();
}
bool bComplete = true;
void subFun()
{
while (true) //for test only,it's a dead loop
{
int[][][] mData = new int[1][][];
for (int i = 0; i < mData.Length; i++)
{
int len = 256 * 1024;//requset for 256KB each time
byte[] buf = new byte[len];
count++;
bComplete = bulkEndptOut.XferData(ref buf, ref len);
}
}
}
|