打印

一执行到FIFORESET就感觉程序跑飞了一样?

[复制链接]
953|5
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
huwr|  楼主 | 2014-12-16 20:06 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
我用CY7C68013,怎么一执行到FIFORESET就感觉程序跑飞了一样?
沙发
huanghuac| | 2014-12-16 20:07 | 只看该作者
不能继续执行了?详细说说

使用特权

评论回复
板凳
huwr|  楼主 | 2014-12-16 20:09 | 只看该作者
我用的是内部时钟。
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;

使用特权

评论回复
地板
happy_10| | 2014-12-16 20:10 | 只看该作者
看波形

使用特权

评论回复
5
huwr|  楼主 | 2014-12-16 20:12 | 只看该作者
看了,发现PA变高后就不变低了,这是怎么回事?

使用特权

评论回复
6
冰清玉洁| | 2014-12-16 20:13 | 只看该作者
不懂,帮你顶下吧

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

780

主题

8627

帖子

5

粉丝