我用CY7C68013,怎么一执行到FIFORESET就感觉程序跑飞了一样?
就不能继续执行了,我用的是内部时钟。
void Dealy_Moment()
{
WORD i;
for( i = 0x0000; i < 0x7FF; i++ )
{
SYNCDELAY;
SYNCDELAY;
}
}
void TD_Init(void) // Called once at startup
{
// set the CPU clock to 48MHz
CPUCS = ((CPUCS & ~bmCLKSPD) | bmCLKSPD1) ;
// set the slave FIFO interface to 48MHz
IFCONFIG |= 0xC3;
// 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 EPxGPIF标志寄存器SEL
// 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
// we are just using the default values, yes this is not necessary...
REVCTL = 0x03; // MUST set REVCTL.0 and REVCTL.1 to 1
SYNCDELAY;
SYNCDELAY;
EP2CFG=0xA0; //需要设定为四缓冲,每个缓冲区大小为512字节
SYNCDELAY;
EP4CFG=0x00;
SYNCDELAY;
EP6CFG=0xE0; //in 2缓冲,大小512Byte
SYNCDELAY;
EP8CFG=0x00;
PORTACFG = 0x00;
SYNCDELAY;
OEA |= 0x0F;
SYNCDELAY;
PA0 = 1;
SYNCDELAY; SYNCDELAY;
SYNCDELAY; SYNCDELAY;
SYNCDELAY; SYNCDELAY;
PA1 = 1;
SYNCDELAY; SYNCDELAY;
SYNCDELAY; SYNCDELAY;
SYNCDELAY; SYNCDELAY;
Dealy_Moment();
SYNCDELAY;
FIFORESET = 0x80; // Reset the FIFO
SYNCDELAY;
FIFORESET = 0x02;
SYNCDELAY;
FIFORESET = 0x06;
SYNCDELAY;
FIFORESET = 0x00;
SYNCDELAY;
PA0 = 0;
SYNCDELAY; SYNCDELAY;
PA1 = 0;
SYNCDELAY; SYNCDELAY;
Dealy_Moment();
// out endpoints do not come up armed
// since the defaults are double buffered we must write dummy byte counts twice
SYNCDELAY;
EP2BCL = 0x80; // arm EP2OUT by writing byte count w/skip.
SYNCDELAY;
EP2BCL = 0x80;
SYNCDELAY;
EP6BCL = 0x80; // arm EP4OUT by writing byte count w/skip.
SYNCDELAY;
EP6BCL = 0x80;
//小于64字节有效
//EP6FIFOPFH=0x00; //DEIS PKSTAT PK2 PK1 PK0 0 PFC9 PFC8
//EP6FIFOPFL=0x40; //PFC7 PFC6 PFC5 PFC4 PFC3 PFC2 PFC1 PFC0
// handle the case where we were already in AUTO mode...
// EP2FIFOCFG = 0x01; // AUTOOUT=0, WORDWIDE=1
SYNCDELAY;
EP6FIFOCFG = 0x09; // AUTOIN=1, ZEROLENIN=0, WORDWIDE=1
SYNCDELAY;
//IO设置
//PORTCCFG = 0x00;
//PORTECFG = 0x00;
//OEC=0x00;
//OEE=0xff;
//串口初始化
// enable dual autopointer feature
AUTOPTRSETUP |= 0x01; |