大家好:
由于第一次用68013,很多地方不太懂,请教一下大家:
问题:使用68013的slave FIFO模式来传输数据,上位机发送数据,下位可以准确收到,但是下位机给上位机发送数据,则显示2次成功,然后一直失败,弄了好久,不知其原因。由于第一次用,我担心,是不是我的初始化配置有问题,我把初始化的代码贴上来给大家看看。请大家指点指点。
void TD_Init( void )
{
CPUCS = 0x12;
IFCONFIG = 0x43;
PORTACFG = 0x40;
SYNCDELAY;
FIFOPINPOLAR = 0x00; // set all slave FIFO interface pins as active low PKTEND OR SLOE SLWR LOW AVTIVE
SYNCDELAY;
REVCTL = 0x03; // enable the external master
SYNCDELAY; //reset the fifos
FIFORESET = 0x80;
SYNCDELAY;
FIFORESET = 0x02;
SYNCDELAY;
FIFORESET = 0x04;
SYNCDELAY;
FIFORESET = 0x06;
SYNCDELAY;
FIFORESET = 0x08;
SYNCDELAY;
FIFORESET = 0x00;
SYNCDELAY;
PINFLAGSAB = 0x00; // PINFLAGSAB = 0xE0; FLAGA - indexed, FLAGB - EP6 FF ;
SYNCDELAY;
PINFLAGSCD = 0x00; // PINFLAGSCD = 0x08; FLAGC - EP2 EF, FLAGD - indexed;
SYNCDELAY; // config the endpoints direction
EP1OUTCFG = 0xA0; //enable and bulk type
EP1INCFG = 0xA0;
SYNCDELAY; // see TRM section 15.14
EP2CFG = 0xA0;
SYNCDELAY;
EP8CFG = 0xE0;
SYNCDELAY;
EP4CFG = 0x00;
SYNCDELAY;
EP6CFG = 0x00;
SYNCDELAY;
OUTPKTEND = 0X82; //arming endpoint 2, perform OUTPKTEND 4 times since EP2 is 4x buffered
SYNCDELAY;
OUTPKTEND = 0X82;
SYNCDELAY;
OUTPKTEND = 0X82;
SYNCDELAY;
OUTPKTEND = 0X82;
SYNCDELAY;
EP2FIFOCFG = 0x10; //EP IS AUTOOUT=0 AUTOIN =1 ZEROLEN=1 WORDIDE=0
SYNCDELAY;
EP8FIFOCFG = 0x08; //EP IS AUTOOUT=0 AUTOIN =1 ZEROLEN=1 WORDIDE=0
SYNCDELAY;
INPKTEND = 0x08;
SYNCDELAY;
INPKTEND = 0x08;
SYNCDELAY;
EP8AUTOINLENH = 0x02; //set the packet size 512
SYNCDELAY;
EP8AUTOINLENL = 0x00;
SYNCDELAY;
EP2BCL = 0x80; // arm EP2OUT by writing byte count w/skip.
SYNCDELAY;
EP2BCL = 0x80;
SYNCDELAY;
} |