Hello
I trying to make transfer to external master from EP4, but empty flag (Flag A in my configuration) is always active. If I don't arm EP4 buffers I see single transfer with right data, but then it stuck again. My code
void TD_Init(void) // Called once at startup
{
// set the CPU clock to 48MHz
CPUCS = ((CPUCS & ~bmCLKSPD) | bmCLKSPD1) ;
IFCONFIG = 0xE3; SYNCDELAY; // Enable slave FIFO Interface @48MHz// KNK
REVCTL = 0x03; SYNCDELAY;
// Endpoints configuration
EP1OUTCFG = 0xA0; SYNCDELAY; // Configure EP1OUT as BULK EP
EP1INCFG = 0xB0; SYNCDELAY; // Configure EP1IN as BULK IN EP
EP4CFG = 0xA0; SYNCDELAY; // Configure EP4 as BULK OUT EP
EP8CFG = 0xE0; SYNCDELAY; // Configure EP8 as BULK IN EP
// FIFO Reset
FIFORESET = 0x80; SYNCDELAY; // NAK all requests from host.
FIFORESET = 0x82; SYNCDELAY; // Reset individual EP (2,4,6,8)
FIFORESET = 0x84; SYNCDELAY;
FIFORESET = 0x86; SYNCDELAY;
FIFORESET = 0x88; SYNCDELAY;
FIFORESET = 0x00; SYNCDELAY; // Resume normal operation.
// Arm buffers
//OUTPKTEND = 0x84; SYNCDELAY;
//OUTPKTEND = 0x84; SYNCDELAY;
// Configure flags
PINFLAGSAB = 0xF9; SYNCDELAY; //FlagA = EP4EF, FlagB = EP8FF
//PINFLAGSCD = 0x08; SYNCDELAY; //FlagC = EP2EF, FlagD = not used
// Fifo Config
EP2FIFOCFG = 0x00; SYNCDELAY; // Disable Wordwide
EP4FIFOCFG = 0x00; SYNCDELAY; // Configure EP4 FIFO in 8-bit Manual mode
EP6FIFOCFG = 0x00; SYNCDELAY; // Disable Wordwide
EP8FIFOCFG = 0x0C; SYNCDELAY; // Configure EP8 FIFO in 8-bit AutoIn mode
PORTACFG = 0x00; SYNCDELAY; // used PA7/FLAGD as a port pin, not as a FIFO flag
FIFOPINPOLAR = 0x00; SYNCDELAY; // set all slave FIFO interface pins as active low
EP8AUTOINLENH = 0x02; SYNCDELAY; // EZ-USB automatically commits data in 512-byte chunks
EP8AUTOINLENL = 0x00; SYNCDELAY;
OEA=0x80;
}
void TD_Poll(void) // Called repeatedly while the device is idle
{
...
EP4FIFOBUF[0] = 0x57;
EP4FIFOBUF[1] = 0x57;
EP4FIFOBUF[2] = 0x57;
EP4FIFOBUF[3] = 0x57;
EP4BCH = 0; SYNCDELAY;
EP4BCL = 4; SYNCDELAY;
...
}
What I did wrong ? I already tryed to reset EP4 FIFO or do OUTPKTEND = 0x04 in TD_Poll but nothing helps.
Alex
|