Hi, I am new to this group. I am using cypress fx2lp usb controller. I have written a loopback firmware for it and successfully downloaded on its ram. On the host side I have written an application which opens the usb device, send some data, read it back, verify and close the device. When I send 512B for the first time loopback works but when I send anything after that loopback fails. Following is code for TD_Init() and TD_Poll(). void TD_Init() { CPUCS = 0x12; // 48 mhz and CLKOUT enabled SYNCDELAY; IFCONFIG = 0xE3; // EP 2 4 6 8 Configuration SYNCDELAY; EP2CFG = 0xE2; // IN BULK 512 Double-Buffered SYNCDELAY; EP4CFG = 0xA0; // OUT BULK 512 Double-Buffered SYNCDELAY; EP6CFG = 0xE2; // IN BULK 512 Double-Buffered SYNCDELAY; EP8CFG = 0xA0; // OUT BULK 512 Double-Buffered // FIFO Reset SYNCDELAY; FIFORESET = 0x80; SYNCDELAY; FIFORESET = 0x02; SYNCDELAY; FIFORESET = 0x04; SYNCDELAY; FIFORESET = 0x06; SYNCDELAY; FIFORESET = 0x08; SYNCDELAY; FIFORESET = 0x00; // Out EP 4 8 Byte Count // Out EP's do not come up armed SYNCDELAY; EP4BCH = 0x00; // Arm EP4OUT by writing to low byte count twice (double buffered) SYNCDELAY; EP4BCL = 0x80; // Arm EP4OUT by writing to low byte count twice (double buffered) SYNCDELAY; EP4BCH = 0x00; // Arm EP4OUT by writing to low byte count twice (double buffered) SYNCDELAY; EP4BCL = 0x80; SYNCDELAY; EP4BCH = 0x00; // Arm EP4OUT by writing to low byte count twice (double buffered) SYNCDELAY; EP8BCL = 0x80; // Arm EP8OUT by writing to low byte count twice (double buffered) SYNCDELAY; EP4BCH = 0x00; // Arm EP4OUT by writing to low byte count twice (double buffered) SYNCDELAY; EP8BCL = 0x80; AUTOPTRSETUP |= 0x01; } void TD_Poll(void) { WORD i; WORD count; if( !(EP2468STAT & bmEP4EMPTY) ) { // check EP4 EMPTY(busy) bit in EP2468STAT (SFR), core set's this bit when FIFO is empty if( !(EP2468STAT & bmEP2FULL) ) { // check EP2 FULL(busy) bit in EP2468STAT (SFR), core set's this bit when FIFO is full APTR1H = MSB( &EP4FIFOBUF ); APTR1L = LSB( &EP4FIFOBUF ); AUTOPTRH2 = MSB( &EP2FIFOBUF ); AUTOPTRL2 = LSB( &EP2FIFOBUF ); count = (EP4BCH << 8) + EP4BCL; // loop EP4OUT buffer data to EP2IN for( i = 0x0000; i < count; i++ ) { // setup to transfer EP4OUT buffer to EP2IN buffer using AUTOPOINTER(s) EXTAUTODAT2 = EXTAUTODAT1; } EP2BCH = EP4BCH; SYNCDELAY; EP2BCL = EP4BCL; // arm EP2IN SYNCDELAY; EP4BCL = 0x80; // re(arm) EP4OUT SYNCDELAY; } } if( !(EP2468STAT & bmEP8EMPTY) ) { // check EP8 EMPTY(busy) bit in EP2468STAT (SFR), core set's this bit when FIFO is empty if( !(EP2468STAT & bmEP6FULL) ) { // check EP6 FULL(busy) bit in EP2468STAT (SFR), core set's this bit when FIFO is full APTR1H = MSB( &EP8FIFOBUF ); APTR1L = LSB( &EP8FIFOBUF ); AUTOPTRH2 = MSB( &EP6FIFOBUF ); AUTOPTRL2 = LSB( &EP6FIFOBUF ); count = (EP8BCH << 8) + EP8BCL; // loop EP8OUT buffer data to EP6IN for( i = 0x0000; i < count; i++ ) { // setup to transfer EP8OUT buffer to EP6IN buffer using AUTOPOINTER(s) EXTAUTODAT2 = EXTAUTODAT1; } EP6BCH = EP8BCH; SYNCDELAY; EP6BCL = EP8BCL; // arm EP6IN SYNCDELAY; EP8BCL = 0x80; // re(arm) EP8OUT SYNCDELAY; } } } I get the following error on second time.. ------------------------------------------ usb 1-2: bulk timeout on ep2in usb 1-2: usbfs: USBDEVFS_BULK failed ep 0x82 len 512 ret -110 usb 1-2: bulk timeout on ep6in usb 1-2: usbfs: USBDEVFS_BULK failed ep 0x86 len 512 ret -110 -------------------------------------------------------------- If anyone know about this problem kindly reply.
LoopBack fails for the second time
Started by ●April 13, 2008