W77E58+RTL8019,不能对RTL8019的IMR和PAR0~PAR5不能操作
[复制链接]
对RTL8019初始化时,代码如下:
unsigned char xdata chRTLInitTmp;
unsigned int i;
//在RSTDRV从高电平回到低电平之后的100MS时,在对RTL8019做读写操作,以确保完全复位
P35 = 1;
for(i = 0;i < 400;i++);
P35 = 0;
for(i = 0;i < 4000;i++);
/* reset: write to reset prot */
WriteReg(0x18,0xaa);
chRTLInitTmp = ReadReg(0x18);
for(i = 0;i < 20;i++);
/* init RTL registers*/
WriteReg(0x00,0x21);
chRTLInitTmp = 0x00;
chRTLInitTmp = ReadReg(0x00);
RTLPage(0);
WriteReg(0x0a,0x00); //清RBCR0
WriteReg(0x0b,0x00); //清RBCR1
WriteReg(0x0c,0xe0); //RCR,监视模式,不接收数据报
WriteReg(0x0d,0xe2); //TCR,loopback模式
WriteReg(0x01, 0x4c); /* Pstart */
WriteReg(0x02, 0x80); /* Pstop */
WriteReg(0x03, 0x4c); /* BNRY */
WriteReg(0x04, 0x40); /* TPSR */
WriteReg(0x07,0xFF); /* ISR: Interrupt Status Register,write FF to clear up all interrupt status */
//WriteReg(0x0f,0x00); /* IMR: Interrupt Mask Register,屏蔽掉所有中断 */
WriteReg(0x0e,0xC8); /* DCR: Data Configuration Register*/
WriteReg(0x0c,0xCE); /* RCR*/
WriteReg(0x0d,0xE0); /* TCR*/
//To debug
chRTLInitTmp = ReadReg(0x07);
chRTLInitTmp = ReadReg(0x0f);
RTLPage(1);
WriteReg(0x07,0x4d); //CURR,设置为指向当前正在写的页的下一页
/* MAR0 */
WriteReg(0x08,0x00);
WriteReg(0x09,0x41);
WriteReg(0x0a,0x00);
WriteReg(0x0b,0x80);
WriteReg(0x0c,0x00);
WriteReg(0x0d,0x00);
WriteReg(0x0e,0x00);
//WriteReg(0x0f,0x00);
/* set phisical address */
RTLPage(1);
WriteReg(1,0x00);
WriteReg(2,0xe0);
WriteReg(3,0x19);
WriteReg(4,0x21);
WriteReg(5,0x68);
WriteReg(6,0x12);
for(i = 0;i < 200;i++);
//To debug
chRTLInitTmp = ReadReg(0x08);
chRTLInitTmp = ReadReg(0x09);
chRTLInitTmp = ReadReg(0x0a);
chRTLInitTmp = ReadReg(0x0b);
chRTLInitTmp = ReadReg(0x0c);
chRTLInitTmp = ReadReg(0x0d);
chRTLInitTmp = ReadReg(0x0e);
//chRTLInitTmp = ReadReg(0x0f);
chRTLInitTmp = ReadReg(0x01);
chRTLInitTmp = ReadReg(0x02);
chRTLInitTmp = ReadReg(0x03);
chRTLInitTmp = ReadReg(0x04);
chRTLInitTmp = ReadReg(0x05);
chRTLInitTmp = ReadReg(0x06);
/* transimit start page */
LastSendStartPage = SEND_START_PAGE0;
StartPageOfPacket = RECEIVE_START_PAGE + 1;
/* in the beginning, no packet is in sending */
InSending = FALSE;
RTLPage(0);
/* initial over, start command and receive */
WriteReg(0x0c,0xcc); //将芯片置于正常模式,跟外部网络连接
WriteReg(0x0d,0xe0);
WriteReg(0x07,0xFF);
chRTLInitTmp = ReadReg(0x07); //清除所有中断标志位
WriteReg(0x00,0x22);