USB low-full-high speed peripherals Forum Discussions
I've two boards with same circuit based on CY7C68014A. Though one of the boards is working fine, other board is not working correctly and windows reports code 43 error during driver installation.
I noticed that non-working board has +3.3V on D+ line. While I'm able to debug the board through serial port, USB connection is not working. Please advise.
Show LessHi All,
I made a modified version of http://www.cypress.com/?docID=42647 with 3 endpoints. For CDC out endpoint i want manual commit so that i can also send data to fpga. But manual commit is not sending data to fpga but automatic commit is working. Nothings seems wrong. Here is the code. I will really appreciate some feedback.
void TD_Init(void) // Called once at startup
{
// Return FIFO setings back to default just in case previous firmware messed with them.
SYNCDELAY; PINFLAGSAB = 0x00;
SYNCDELAY; PINFLAGSCD = 0x00;
SYNCDELAY; FIFOPINPOLAR = 0x00;
// Global settings
SYNCDELAY; REVCTL = 0x03;
SYNCDELAY; CPUCS = ((CPUCS & ~bmCLKSPD) | bmCLKSPD1); // 48MHz
// IFCLKSRC 3048MHZ IFCLKOE IFCLKPOL ASYNC GSTATE IFCFG1 IFCFG0
SYNCDELAY; IFCONFIG = 0xE3; //1110 0011
// EP1OUT & EP1IN
SYNCDELAY; EP1OUTCFG = 0x00;
SYNCDELAY; EP1INCFG = 0xA0;
// VALID DIR TYPE1 TYPE0 SIZE 0 BUF1 BUF0
SYNCDELAY; EP2CFG = 0xA2;
SYNCDELAY; EP4CFG = 0xE2;
SYNCDELAY; EP6CFG = 0xD0;//1101 0000
SYNCDELAY; EP8CFG = 0x00;
// 0 INFM1 OEP1 AUTOOUT AUTOIN ZEROLENIN 0 WORDWIDE
SYNCDELAY; EP2FIFOCFG = 0x00;
// SYNCDELAY; EP2FIFOCFG = 0x10;
SYNCDELAY; EP4FIFOCFG = 0x0C;
SYNCDELAY; EP6FIFOCFG = 0x0C;
SYNCDELAY; EP8FIFOCFG = 0x00;
SYNCDELAY; EP4AUTOINLENH = 0x02;
SYNCDELAY; EP4AUTOINLENL = 0x00;
SYNCDELAY; EP6AUTOINLENH = 0x02;
SYNCDELAY; EP6AUTOINLENL = 0x00;
SYNCDELAY; FIFORESET = 0x80;
SYNCDELAY; FIFORESET = 0x82;
SYNCDELAY; FIFORESET = 0x84;
SYNCDELAY; FIFORESET = 0x86;
SYNCDELAY; FIFORESET = 0x00;
SYNCDELAY; OUTPKTEND = 0x82;
SYNCDELAY; OUTPKTEND = 0x82;
}
void TD_Poll(void) // Called repeatedly while the device is idle
{
if( !( EP2468STAT & 0x01 ) )
{ // EP2EF=0 when FIFO NOT empty, host sent packet
OUTPKTEND = 0x02; // SKIP=0, pass buffer on to master
}
if (!(EP1INCS & 0x02)) // check if EP1IN is available
{
EP1INBUF[0] = 0x0A; // if it is available, then fill the first 10 bytes of the buffer with
EP1INBUF[1] = 0x20; // appropriate data.
EP1INBUF[2] = 0x00;
EP1INBUF[3] = 0x00;
EP1INBUF[4] = 0x00;
EP1INBUF[5] = 0x00;
EP1INBUF[6] = 0x00;
EP1INBUF[7] = 0x02;
EP1INBUF[8] = 0x00;
EP1INBUF[9] = 0x00;
EP1INBC = 10; // manually commit once the buffer is filled
}
}
Show LessHi All,
Here is an Example project on Keyboard Implementation using Encore V . This is a wired keyboard example project which supports standard 104 key keyboard. It also has other features like
1) Ghost key detection
2) USB Suspend
3) USB remote Wakeup
4) Power button - Sleep, shutdown
5) CD controls: play/pause, stop, fwd/next, and back/previous
6) Volume Controls: up, down, mute
7) Internet keys: WWW browser, e-mail, search, backward, forward, and favorite
😎 Debounce for all button press
Attached along with this project is an Excel sheet giving the details of Keyboard Matrix.
Regards,
SRAM
Show LessHi All,
Here is an Example project on Keyboard Implementation using Encore V . This is a wired keyboard example project which supports standard 104 key keyboard. It also has other features like
1) Ghost key detection
2) USB Suspend
3) USB remote Wakeup
4) Power button - Sleep, shutdown
5) CD controls: play/pause, stop, fwd/next, and back/previous
6) Volume Controls: up, down, mute
7) Internet keys: WWW browser, e-mail, search, backward, forward, and favorite
😎 Debounce for all button press
Attached along with this project is an Excel sheet giving the details of Keyboard Matrix.
Regards,
SRAM
Show LessDear sir,
i ahve developed one code to download my firmware to cypress FX2LP. i am using the cyusb's cyusb_control_transfer and i am catching the sent bytes and i get perfect match between the Bytes sent and the firmware file size
but sad part is my device doesnt get initialised
Note: Firmware is tested n works fine
i am pasting here my code please do rply and give suggestions.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "../../include/cyusb.h"
unsigned int DownloadFirmware();
int main (void)
{
unsigned int a = 0;
a = DownloadFirmware();
if(a == 1)
{
printf("\nsuccessful fd\n");
}
}
unsigned int DownloadFirmware()
{
cyusb_handle *h;
int size, r;
int a, b, c, flag;
int Sum = 0, Done = 0;
const char *cbuf;
const char *filename = "/home/usb/FPR/firmware/fw.bix";
unsigned char *buf = NULL;
unsigned char *ptr;
unsigned char num_bytes = 0;
unsigned short address = 0;
unsigned char reset = 0;
FILE *fp; /* file pointer */
struct libusb_device_descriptor desc;
a = cyusb_open();
if ( a < 0 ) {
printf("Error opening library\n");
return -1;
}
else if ( a == 0 ) {
printf("No device foundd\n");
}
h = cyusb_gethandle(0);
b = cyusb_get_device_descriptor(h, &desc);
if(b){
printf("error getting device descriptor\n");
return -2;
}
struct stat st;
stat(filename, &st);
size = st.st_size;
printf("size of file = %d\n", size);
buf = (unsigned char*)malloc(size);
/* open file for read */
if ((fp = fopen("/home/usb/FPR/firmware/fw.bix", "r"))==NULL){
printf("Cannot open file \n");
}
fread(buf, size, 1 ,fp);
fclose(fp);
if(buf)
printf("file copied");
int ChunkSize = 4000; // seem to sending 4000 but not 5000 at one time
int BlockSize = size;
int entry = 0;
reset = 1;
sleep(1);
reset = 0;
r = cyusb_control_transfer(h, 0x40, 0xA0, 0xE600, 0x00, &reset, 0x01, 1000);
if (!r) {
printf("Error in control_transfer\n");
return r;
}
sleep(1);
sleep(1);
ptr = buf;
while(!Done)
{
if(BlockSize < ChunkSize){
address += ChunkSize;
// buf = buf+ChunkSize;
ptr = ptr + ChunkSize;
ChunkSize = BlockSize;
flag = 1;
}
r = cyusb_control_transfer(h, 0x40, 0xA0, address, 0x00, ptr, ChunkSize, 30);
printf("\nturn no. %d\n", r);
if (!r) {
printf("Error in control_transfer. . .\n");
return r;
}
// buf = buf+ChunkSize;
ptr = ptr + ChunkSize;
BlockSize -= r;
Sum += r;
if(Sum == size)
Done = 1;
printf("\nsum = %d\n", Sum);
}
sleep(1);
reset = 1;
r = cyusb_control_transfer(h, 0x40, 0xA0, 0xE600, 0x00, &reset, 0x01, 1000);
reset = 0;
r = cyusb_control_transfer(h, 0x40, 0xA0, 0xE600, 0x00, &reset, 0x01, 1000);
sleep(2);
if(Done == 1){
return 1;
free(buf);
}
}
please help me i want to get out of this
Thanks in advance
Regards
Rohaan
Show LessHi,
I downloaded a .iic file by mistake on the FX2LP EEPROM (the file was taken from the SuiteUSB examples). Now I would like to restore the factory firmware, or to restore the situation in which the USB was recognized as "EEPROM Missing" when connected to the PC. How can I do?
Thank you in advance,
Alessandro
Show LessI think I posted in the wrong forum previously, so I am going to repost my problem here. I have constructed an interface using an FPGA to drive the EP2FIFO. I am using the EP2FIFO FF as FLAGB, and the FPGA uses the flag to tell it when to stop sending data. Data is requested using EP8, and that part is working fine. However, EP2FIFO FF is going high after 64 bytes, which made me think the EP was working in low speed mode. However, I can see, using UCView, that the max packet size for the EP2 is 512 bytes, and the connection is high speed. I have to believe I m making an obvious mistake, but I do not see it. Here is my EPSetup:
void EPSetup(void)
{
// HistctrlReset(1);
REVCTL=0x1; // Enhanced Packet Handling
// set the slave FIFO interface to 48MHz
IFCONFIG = 0x03; // IFCLKSRC=0 , FIFOs executes on external clk source
// xMHz=0 , 48MHz internal clk rate
// IFCLKOE=0 , Don't drive IFCLK pin signal at 48MHz
// IFCLKPOL=0 , Don't invert IFCLK pin signal from internal clk
// ASYNC=0 , master samples asynchronous
// GSTATE=0 , Don't drive GPIF states out on PORTE[2:0], debug WF
// IFCFG[1:0]=11, FX2 in slave FIFO mode
SYNCDELAY;
// set up registers for EndPoint communication
// Registers which require a synchronization delay, see section 15.14
// FIFORESET FIFOPINPOLAR
// INPKTEND OUTPKTEND
// EPxBCH:L REVCTL
// GPIFTCB3 GPIFTCB2
// GPIFTCB1 GPIFTCB0
// EPxFIFOPFH:L EPxAUTOINLENH:L
// EPxFIFOCFG EPxGPIFFLGSEL
// PINFLAGSxx EPxFIFOIRQ
// EPxFIFOIE GPIFIRQ
// GPIFIE GPIFADRH:L
// UDMACRCH:L EPxGPIFTRIG
// GPIFTRIG
// Note: The pre-REVE EPxGPIFTCH/L register are affected, as well...
// ...these have been replaced by GPIFTC[B3:B0] registers
// default: all endpoints have their VALID bit set
// default: TYPE1 = 1 and TYPE0 = 0 --> BULK
// default: EP2 and EP4 DIR bits are 0 (OUT direction)
// default: EP6 and EP8 DIR bits are 1 (IN direction)
// default: EP2, EP4, EP6, and EP8 are double buffered
// reset EP FIFOs
// Reset all FIFOs
SYNCDELAY;
FIFORESET = 0x80; // activate NAK-ALL to avoid race conditions
SYNCDELAY; // see TRM section 15.14
EP8FIFOCFG=0x01; //Use WORDWIDE
SYNCDELAY;
EP2FIFOCFG=0x05; // use ZEROLENIN,WORDWIDE
SYNCDELAY;
FIFORESET = 0x02; // reset, FIFO 2
SYNCDELAY; //
FIFORESET = 0x04; // reset, FIFO 4
SYNCDELAY; //
FIFORESET = 0x06; // reset, FIFO 6
SYNCDELAY; //
FIFORESET = 0x08; // reset, FIFO 8
SYNCDELAY; //
FIFORESET = 0x00; // deactivate NAK-ALL
SYNCDELAY;
SYNCDELAY;
EP1OUTCFG=0xA0; //Bit 7 - Valid=1;
//Bit 6 - NC 0
//Bit [5..4] - TYPE=BULK(0x2);
//Bit 3 - Size=512(0);
//Bit 2 - 0
//Bit [1..0] - 0
SYNCDELAY;
EP1INCFG=0xA0; //Bit 7 - Valid=1;
//Bit 6 - NC 0
//Bit [5..4] - TYPE=BULK(0x2);
//Bit 3 - Size=512(0);
//Bit 2 - 0
//Bit [1..0] - 0
EP1OUTBC=0;
SYNCDELAY;
// Set up endpoints
// Bit Task
// 7 VALID - turns on EP if 1
// 6 DIR - 0=out;1=in
// 5..4 TYPE - 0=invalid;1=ISO;2=bulk;3=interrupt
// 3 SIZE - 0=512;1=1024
// 2 NC
// 1..0 BUF - 0=quad;1=invalid;2=double;3=triple
// EP1 is bidirectional
SYNCDELAY;
EP2CFG = 0xE2; //Bit 7 - Valid=1;
//Bit 6 - DIR - 0=out;1=in
//Bit [5..4] - TYPE=BULK(0x2);
//Bit 3 - Size=512(0);
//Bit 2 - 0
//Bit [1..0] - BUF=DOUBLE(0x2)
SYNCDELAY;
EP8CFG = 0xA0; //Bit 7 - Valid=1;
//Bit 6 - DIR=OUT(0);
//Bit [5..4] - TYPE=BULK(0x2);
//Bit 3 - Size=512(0);
//Bit 2 - 0
//Bit [1..0] - BUF=DOUBLE(0x2)
SYNCDELAY;
// Unused EPs still take up memory if they are not configured LAST.
// FIFO memory is first come, first allocated.
SYNCDELAY;
EP4CFG = 0x2; // disable; only double buffered
SYNCDELAY;
EP6CFG = 0x2; // disable; only double buffered
// Set up FIFO Operations
// Bit Task
// 7 NC
// 6 INEARLY - if 1, causes IN flags to appear one clock cycle earlier
// 5 OUTEARLY - if 1, causes OUT flags to appear one clock early
// 4 AUTOOUT - if 1, data is auto-committed to USB (only used for OUT FIFO)
// 3 AUTOIN - if 1, uses PKTLEN register
// 2 ZEROLENIN - if 1, a PKTEND commits a zero-length packet
// 1 NC
// 0 WORDWIDE - if 1, data is 16 bits wide
// EP8FIFOCFG=0x11; //Use AUTOOUT,WORDWIDE
EP8FIFOCFG=0x11; //Use AUTOOUT,WORDWIDE
SYNCDELAY;
EP2FIFOCFG=0x0D; // use AUTOIN,ZEROLENIN,WORDWIDE
SYNCDELAY;
// set up autoin length to be 512. if we are not high speed, we can only send
// a maximum of 64 byte packets (see Descriptor). The AUTOINLEN must be the same
// as the max packet in the descriptor.
if(EZUSB_HIGHSPEED())
{
EP2AUTOINLENH=0x02;
SYNCDELAY;
EP2AUTOINLENL=0x00;
SYNCDELAY;
}
else
{
EP2AUTOINLENH=0x00;
SYNCDELAY;
EP2AUTOINLENL=0x40;
SYNCDELAY;
}
// EP2 FF = 0xC EP8EF= 0xB
// PINFLAGSAB=0xC8;
PINFLAGSAB=0xCB;
SYNCDELAY;
// PINFLAGSCD=0xFB;
PINFLAGSCD=0xBB;
SYNCDELAY;
PORTACFG |= 0x80; // FLAGD, set alt. func. of PA7 pin
SYNCDELAY;
FIFOPINPOLAR=0x3; // we want all flags to be active high
SYNCDELAY;
// out endpoints do not come up armed
// since the defaults are double buffered we must force 2 packets
SYNCDELAY; //
OUTPKTEND=0x88;
SYNCDELAY;
OUTPKTEND=0x88;
// enable dual autopointer feature
AUTOPTRSETUP |= 0x01;
}
Hello!
I read documentation on CY768013 chapter 10 about GPIF, but can't understand how specific waveform chosen at the right moment. For instance, i have 4 waveform (read, write, fifo read, fifo write).When i call single read function, how it choose needed waveform. Can anyone explain me?