|
使用的端点:EP2 OUT, EP6 IN。 4倍缓存,512字节长。
使用驱动:早期 EZUSB驱动
碰到的问题是这样的:现象EP2空的时候,HOST发送数据给FX2 的时候,系统死锁。 主要 是SLAVEFIFO写入大批量数据后,主机发送第四个OUT包死锁。
以为EP2没有ARM,但四 查看了EP2468STAT = 0x99, EP2CS = 0x04; 可以排除应用程序的问题,因为我用BUSHOUND调试,也死锁。
还有什么寄存器可以检查吗?
void TD_Init(void) // Called once at startup
{
//--CPUCS = ((CPUCS & ~bmCLKSPD) | bmCLKSPD1) ;
CPUCS = bmCLKSPD1; //++. CLKOUT = 48MHz, disable CLKOUT output, portc rd#/wr# disabled.
IFCONFIG = 0xA3; //++.
CKCON |= 0x12; //++. T2M=0; T1M=1; T0M=0; note external memory stretch is defined in fx2.h and set at fw.c
WAKEUPCS = 0x00; //++ disable WU2EN, disable DPEN to disable USB resume.
PORTACFG = 0x40; //++. PA.0/1 is input IO,PA.7 is SLCS.
OEA = 0x08; //++ PA3 is output.
IOA = 0x00; //++ PA3 will will output 0 to reset local CPLD.
I2CTL = 0x01; //++ set IIC 400KHz
// 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
// REVCTL = 0x00; //++.
// SYNCDELAY;
EP1OUTCFG = 0x30; //++. EP1OUT invalid, type is interrupt
SYNCDELAY;
EP1INCFG = 0xb0; //++. EP1IN valid, type is interrupt
SYNCDELAY;
EP2CFG = 0xA0; //++. EP2: valid, OUT, bulk, 512byte packet size, quad buffering. 20091118
SYNCDELAY;
EP4CFG = 0x20; //++. EP4 invalid,
SYNCDELAY;
EP6CFG = 0xE0; //++. EP6: valid, IN, bulk, 512byte packet size, quad buffering
SYNCDELAY;
EP8CFG = 0x20; //++. EP8: invalid
SYNCDELAY;
//reset all FIFO
FIFORESET = 0x80;
SYNCDELAY;
FIFORESET = 0x02;
SYNCDELAY;
FIFORESET = 0x06;
SYNCDELAY;
FIFORESET = 0x00;
SYNCDELAY;
EP2FIFOCFG = 0x01; //EP2 AUTOOUT=0; AUTOIN=0; slave fifo width is 16bit. 20091118
SYNCDELAY;
EP6FIFOCFG = 0x09; //EP6 auto in, slave fifo wide is 16bit.
SYNCDELAY;
// Now EP2 is quad buffer
EP2BCL = 0x80; // arm EP2OUT by writing byte count w/skip.
SYNCDELAY;
EP2BCL = 0x80;
SYNCDELAY;
EP2BCL = 0x80;
SYNCDELAY;
EP2BCL = 0x80;
SYNCDELAY;
PINFLAGSAB = 0x8e; //FLAGA is EP6 full flag; FLAGB is empty flag of EP2. 20091118
SYNCDELAY;
FIFOPINPOLAR = 0x03; //PKTEND,SLOE,SLWR,SLRD are low active, FE,FF is high active
SYNCDELAY;
// enable dual autopointer feature
AUTOPTRSETUP |= 0x01;
} |
阿莫论坛20周年了!感谢大家的支持与爱护!!
曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
|