Nephazz
Junior Member level 1
Hi,
my current project is to establish an USB connection between a WinXP PC and an FPGA. I don't get my hands dirty on the FPGA though, my boss does this stuff. He needs me to provide datarate of at least 15 MB/s. I've got a board which has "Cypress semiconductor CY3684 / 3674 EZ-USB Advanced development board" printed on and a "CY7C68013A-128AXC 0731 B 04 645490" chip mounted. I use this to develop my WinXP software (MS Visual C++) but the final version will use an FPGA Board from AVnet. The current firmware for the CY7 USB-Controller is the bulkloop.hex deliverd in c:/cypress/usb/examples.
Right now I use the CyAPI and I'am able to establish a connection to the board, get some informations like "number of endpoints" and bulk transfer in and out. To meassure the tranferspeed I use . (source file is attached) Unfortunatly I only get about 1 MB/s. ( I've tried using https://www.cypress.com/?docID=4383 to meassure speed but I can't get it running. It's probably because I use "USB Console" instead of "EZ-USB Control Panel" which I can't find anywhere. )
So ... where is my bottleneck? Is CyAPI in general unable to attain high bandwidth? Do I use it wrong or is it just the expample firmware that doesn't deliver? Do you have any app notes or other must-reads?
have a nice day,
Jan
PS: this is crossposted in https://www.cypress.com/forums/forum/messageview.cfm?catid=8&threadid=10046&enterthread=y
my current project is to establish an USB connection between a WinXP PC and an FPGA. I don't get my hands dirty on the FPGA though, my boss does this stuff. He needs me to provide datarate of at least 15 MB/s. I've got a board which has "Cypress semiconductor CY3684 / 3674 EZ-USB Advanced development board" printed on and a "CY7C68013A-128AXC 0731 B 04 645490" chip mounted. I use this to develop my WinXP software (MS Visual C++) but the final version will use an FPGA Board from AVnet. The current firmware for the CY7 USB-Controller is the bulkloop.hex deliverd in c:/cypress/usb/examples.
Right now I use the CyAPI and I'am able to establish a connection to the board, get some informations like "number of endpoints" and bulk transfer in and out. To meassure the tranferspeed I use . (source file is attached) Unfortunatly I only get about 1 MB/s. ( I've tried using https://www.cypress.com/?docID=4383 to meassure speed but I can't get it running. It's probably because I use "USB Console" instead of "EZ-USB Control Panel" which I can't find anywhere. )
So ... where is my bottleneck? Is CyAPI in general unable to attain high bandwidth? Do I use it wrong or is it just the expample firmware that doesn't deliver? Do you have any app notes or other must-reads?
have a nice day,
Jan
PS: this is crossposted in https://www.cypress.com/forums/forum/messageview.cfm?catid=8&threadid=10046&enterthread=y
Code:
//***********************************************************
//***********************************************************
//
// File: Test_CyAPI.cpp
// Date: 7.4.10
// Author: Kießling, Jan P.
// Purpose: getting used to CyAPI and writing basic
// functions
//***********************************************************
//***********************************************************
//***********************************************************
// Includes
//***********************************************************
#include <windows.h>
#include <stdio.h>
//#include <iostream.h>
#include <time.h>
#include <conio.h>
#include <math.h>
#include <CyAPI.h>
#include <string>
#include <iostream>
//***********************************************************
// Macros and Global Variables
//***********************************************************
using namespace std;
extern HANDLE Handle;
using std::string;
//***********************************************************
// Declarations
//***********************************************************
bool USBSend512(unsigned char *out, CCyUSBDevice *USBDevice);
bool USBGet512(unsigned char *in, CCyUSBDevice *USBDevice);
void wait_seconds(int seconds);
//***********************************************************
// main
//***********************************************************
void main (void)
{
// [USB Init]
CCyUSBDevice *USBDevice = new CCyUSBDevice(NULL);
// Attempt to open device #0
if (USBDevice->DeviceCount() && !USBDevice->Open(0)) // check if there is a device available and if device0 is NOT already open
{
cout << "Resetting and opening Device 0" << endl;
USBDevice->Reset();
USBDevice->Open(0);
}
if (! USBDevice->IsOpen())
{
printf("\n Device NOT open\n\n");
}
else
{
printf("\n Device open\n\n");
}
// [get information]
int devices = USBDevice->DeviceCount();
int altInt = USBDevice->AltIntfcCount();
int curInt = USBDevice->AltIntfc();
int eptCount = USBDevice->EndPointCount();
int maxPaketSize = USBDevice->BulkOutEndPt->MaxPktSize;
// [print information]
cout << "FriendlyName: " << USBDevice->FriendlyName << endl;
//cout << "Number of Cypress Devices: " << devices << endl;
cout << "Number of alternate interfaces: " << altInt << endl;
cout << "Using Interface: " << curInt << endl;
cout << "Number of Endpoints: " << eptCount << endl;
cout << "Max Paket Size of Bulk Out 1: " << maxPaketSize << endl;
cout << "Xfer Size = " << USBDevice->BulkOutEndPt->GetXferSize() << endl;
// [report all Endpoints with type and direction]
string direction, type;
for(int c = 0; c < eptCount; c++)
{
if(USBDevice->EndPoints[c]->bIn)
{
direction = "Input";
}
else
{
direction = "Output";
}
switch(USBDevice->EndPoints[c]->Attributes)
{
case 0:
type = "Control";
break;
case 1:
type = "Isochronous";
break;
case 2:
type = "Bulk";
break;
case 3:
type = "Interrupt";
break;
}
cout << "Endpoint " << c << " is " << type << " " << direction << endl;
}
//[Speed Test]
unsigned char out[512];
unsigned char in[512];
time_t t_start, t_end;
double t_elapsed;
//init arrays
for (c = 0; c < 513; c++)
{
out[c] = 0x00+c;
in[c] = 0x01;
}
//start test
time(&t_start); //get current time
for(double ac=0; ac < 65535; ac++)
{
USBSend512(out, USBDevice);
USBGet512(in, USBDevice);
}
time(&t_end);
t_elapsed = difftime(t_end,t_start);
cout << " " << t_elapsed << endl;
//[are the last two arrays equal?]
bool ka = TRUE;
for(c = 0; c < 512; c++)
{
if(in[c] != out[c])
{
ka = FALSE;
}
}
if(ka)
{
cout << "In equals Out" << endl;
}
else
{
cout << "In doesn't equal Out" << endl;
}
//[End of Main]
USBDevice->Close();
return;
}
//***********************************************************
// functions
//***********************************************************
bool USBSend512(unsigned char *out, CCyUSBDevice *USBDevice)
{
//this function sends 512 Bytes via USB to an open Endpoint
//returns TRUE if OK, false if no EP exists
bool OK = FALSE;
LONG length = 512;
if (USBDevice->BulkOutEndPt) //check if EP exists
{
OK = (USBDevice->BulkOutEndPt->XferData(out, length)); //sending array
}
else
{
OK = FALSE;
}
return OK;
}
//***********************************************************
bool USBGet512(unsigned char *in, CCyUSBDevice *USBDevice)
{
//this function gets 512 Bytes via USB from an open Endpoint
//returns TRUE if OK, false if no EP exists
bool OK = FALSE;
LONG length = 512;
if (USBDevice->BulkInEndPt) //check if EP exists
{
OK = USBDevice->BulkInEndPt->XferData(in, length);
}
else
{
OK = FALSE;
}
return OK;
}
//***********************************************************
void wait_seconds(int seconds)
{
clock_t endwait;
endwait = clock () + seconds * CLOCKS_PER_SEC ;
while (clock() < endwait)
{
}
}