USB low-full-high speed peripherals Forum Discussions
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
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 http://www.edaboard.com/thread188074.html (code is way better to read there, due to working
Show Less
PPS: lol, no *.cpp or *.txt attach allowed?
//***********************************************************
//***********************************************************
//
// File: Test_CyAPI.cpp
// Date: 7.4.10
// Author: Kießling, Jan P.
// Purpose: getting used to CyAPI and writing basic
// functions
//***********************************************************
//***********************************************************
//***********************************************************
// Includes
//***********************************************************
#include
#include
//#include
#include
#include
#include
#include
#include
#include
//***********************************************************
// 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->bIn)
{
direction = "Input";
}
else
{
direction = "Output";
}
switch(USBDevice->EndPoints->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= 0x00+c;
in= 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!= out )
{
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)
{
}
}
i just find 68013 datesheet ,and it contain register address,but i want more
Hi,
i use the cyusb.sys (The driver of Window xp version) and the cyApi,the speed of usb can reach about 30M/ S, but if i use the cyusb.sys(The driver of Window 7 version),the speed is very slow, The application code is exactly the same, In addition: In the application code, i use BeginDataXfer、WaitForXfer、FinishDataXfer and the code is used to capture camera data, the preview size maybe 640X480, 800X600,1600X1200 or 30M, in window7,if the usb is too slow,then i can not capture complete frames, this problem disturbed me greatly! who can help me????
Show LessHi,
I have been trying to solove the following issue:
PC side: Two Bulk Endpoints (in, out), the Out endpoint is called from within the GUI thread (i.e. when you press a button). The In endpoint runs on its own thread by calling mDevice->BulInEndpoint->XferData(..........).
On the Emdedded side I have PSoC5 device. Basically I have a while loop:
"if there is data on the PC's out enbdpoint then read it and load it on the PCs in point"
So if the user does not press a button on the GUI, then there is no data flowing; when one presses the button, then a 4-byte packet is sent from the PC to the PSoC5 and looped back to the PC.
This works fine IF the PC's In endpoint does not time out. If the IN endpoint times out, then for some reason the PC is not able to receive data anymore. I have tried different scheemes (using Begin and Finish DataXfer, calling Abort, etc) but none work.
I am programming in .net 2005 (Windows Form).
Now, I have a very simple application , same concept of receiving thread -win32 console app CyAPI.lib, but using one of the FX chips and have no issues. Thus I don't know if is a .net vs win32 issue or what.
Any ideas?
Thank you.
Show LessHi
i have a problem
I'm trying to implement a loop back similar to exemple bulkscr but i want not to use the autopointer for copy endpoint out to enpoint in (for read my write). I would like access to ram by make the copy directly.
I tried to use the command
for (i=0;i<512;i++)
EP6FIFOBUF =EP2FIFOBUF; // EP2 OUT and EP6 input
but doesn't work
is the assigment correct for fifo ram buffer?
thanks a lot
Show LessSorry for my english.
Controller - cy7c6801 - 56pins.
From the examples I do not understand how you can easily convey the state of input-output ports on the usb in my application. If not hard - give a simple example for learning (very desirable in the C language).
Thanks in advance!
Camera Sensor CY7C68013A
PIXCLK------------> IFCLK
LINE_Sync--------> SLWR
FRAME_Sync-----> PKTEND
Data0..7-----------> FD0..FD7
I referred “9.Slave FIFO” in Technical Manual.
This article published on EETimes was written by Dhanraj Rajput, a member of the USB Apps group, and talks about how to design secure USB-based dongles.
See the full article at: www.eetimes.com/design/industrial-control/4233538/How-to-design-secure-USB-based-dongles
Show LessIs it possible to access the 64-bit cyusb.sys from a 32-bit application? I have a fixed 32-bit app that communicates with external cypress-based usb devices using dll plugins but I don't know exactly how to achieve 32-64-bit bridging.
Please help.
Show Less