|
Thanks for the response. I finally got time to work on this..
So I implemented your suggested change, and I am still getting the same result. Note that if I dont read from the EP0 Buf and I hardcode values, everything is correct... so it defininately appears to be an issue with the EP0 buffer.
My exact code is:
TD_Init:
// set the CPU clock to 48 MHz
CPUCS = ((CPUCS & ~bmCLKSPD) | bmCLKSPD1);
EP1OUTCFG = 0xA0; //EP1OUT, bulk, OUT, 64 bytes, single buffered
SYNCDELAY;
EP1INCFG = 0xA0; //EP1IN, bulk, IN, 64 bytes, single buffered
SYNCDELAY;
EP2CFG = 0xA2; // EP2OUT, bulk, size 512, 2x buffered
SYNCDELAY;
EP4CFG = 0x00; // EP4 not valid
SYNCDELAY;
EP6CFG = 0xE2; // EP6IN, bulk, size 512, 2x buffered
SYNCDELAY;
EP8CFG = 0x00; // EP8 not valid
SYNCDELAY;
EP2FIFOCFG = 0x01; // manual mode, disable PKTEND zero length send, word ops
SYNCDELAY;
EP6FIFOCFG = 0x01; // manual mode, disable PKTEND zero length send, word ops
SYNCDELAY;
FIFORESET = 0x80; // set NAKALL bit to NAK all transfers from host
SYNCDELAY;
FIFORESET = 0x02; // reset EP2 FIFO
SYNCDELAY;
FIFORESET = 0x06; // reset EP6 FIFO
SYNCDELAY;
FIFORESET = 0x00; // clear NAKALL bit to resume normal operation
SYNCDELAY;
// Arm endpoint with # bytes to transfer
// out endpoints do not come up armed
// since EP2OUT is quad buffered we must write dummy byte counts four times
EP0BCL = 0;
SYNCDELAY;
EP2BCL = 0x80; // arm EP2OUT by writing byte count w/skip.
SYNCDELAY;
EP2BCL = 0x80;
SYNCDELAY;
EP2BCL = 0x80;
SYNCDELAY;
EP2BCL = 0x80;
SYNCDELAY;
GpifInit (); // initialize GPIF registers
OEA |= 0x03;
Vendor Command:
case VR_SET_ADDRESS:
while(!(GPIFTRIG & 0x80)); //While GPIF is busy
IOA |= 0x2; //Set address enable bit
for(i=0; i<SETUPDAT[6]; ++i) {
while(EP0CS & bmEPBUSY);
SYNCDELAY;
XGPIFSGLDATH = EP0BUF[i++];
SYNCDELAY;
XGPIFSGLDATLX = EP0BUF[i];
while(!(GPIFTRIG & 0x80)); //While GPIF is busy
}
IOA ^= 0x2; //Disable address bit
EP0BCH = 0;
EP0BCL = 0; // Arm endpoint with # bytes to transfer
EP0CS |= bmHSNAK; // Acknowledge handshake phase of device request
break;
Thank you again!
|