In older fx2 firmware code I'm leaving the REVCTL register alone but due to some (other) EP problems I'm having, I figured I should set REVCTL's DYN_OUT and ENH_PKT bits. With these bits set (according to the fx2 technical reference manual) one doesn't need to induce a 0->1 transition on EPnFIFOCFG to arm the endpoint (fx2 trm 15-24). However, endpoints are now armed by writing to OUTPKTEND. I'm using quad- buffering on EP2 and writing OUTPKTEND=0x82 four times. Even after doing this the endpoint never gets armed. Any ideas?
When I say it doesn't get armed, I mean that I can't write to the thing with my PC _and_ the EP2CS register says the EP2 FIFO is full after a fresh reset (when DYN_OUT bit is not set the EP2 FIFO is _not_ full after a fresh reset).
The code below produces the error: (the code below still induces the 0->1 transition on EP2FIFOCFG, the code operates the same with or without this transition)
CPUCS = bmCLKSPD1; // CPU runs @ 48 MHz CKCON = 0; // MOVX takes 2 cycles
// Slave FIFO, sync mode, 48MHz clock IFCONFIG = bmIFCFGMASK|bmIFCLKSRC|bmIFCLKOE|bmIFCLKPOL|bm3048MHZ; SYNCDELAY;
WAKEUPCS=0; REVCTL = bmDYN_OUT | bmENH_PKT; // highly recommended by docs
EP1OUTCFG = bmVALID | bmBULK; SYNCDELAY; EP1INCFG = bmVALID | bmBULK | bmIN; SYNCDELAY;
EP2CFG = bmVALID | bmBULK | bmQUADBUF; SYNCDELAY; // 512 quad bulk OUT EP4CFG = 0; SYNCDELAY; // disabled EP6CFG = bmVALID | bmBULK | bmQUADBUF | bmIN; SYNCDELAY; // 512 quad bulk IN EP8CFG = 0; SYNCDELAY; // disabled
// reset FIFOs
FIFORESET = bmNAKALL; SYNCDELAY; FIFORESET = 2; SYNCDELAY; FIFORESET = 6; SYNCDELAY; FIFORESET = 0; SYNCDELAY;
OUTPKTEND=0x82; OUTPKTEND=0x82; OUTPKTEND=0x82; OUTPKTEND=0x82;
// configure end point FIFOs // let core see 0 to 1 transistion of autoout bit EP2FIFOCFG = bmWORDWIDE; SYNCDELAY; EP2FIFOCFG = bmAUTOOUT | bmWORDWIDE; SYNCDELAY; EP6FIFOCFG = bmAUTOIN | bmWORDWIDE; SYNCDELAY;
EP0BCH = 0; SYNCDELAY;
// arm EP1OUT so we can receive "out" packets (TRM pg 8-8) EP1OUTBC = 0; SYNCDELAY;
EP6AUTOINLENH = (512) >> 8; SYNCDELAY; // this is the length for high speed EP6AUTOINLENL = (512) & 0xff; SYNCDELAY;