最近在做一个TCP/IP的东东,刚好使用RTL8019AS芯片,在编写驱动程序的时候,对芯片进行初始化以后,进行读取ISR和CURR寄存器,发现两个寄存器的值都是0xFF,颇感郁闷,在此向各位大虾请教一下。具体初始化代码如下:
//==========================================
//软件复位部分
//==========================================
// 选择页
RealTekSelectPage(0);
// 切换到正常工作方式
RealTekWriteREG(&pRealTekReg->reg0w.CR, pRealTekReg, 0x22);
// 对芯片进行复位操作
OSTimeDly(OS_TICKS_PER_SEC >> 4);
value = RealTekReadREG(pRealTekReg->reg0r.ResetPort, pRealTekReg);
RealTekWriteREG(pRealTekReg->reg0w.ResetPort, pRealTekReg, (BYTE)value);
OSTimeDly(OS_TICKS_PER_SEC >> 4);
// 使网卡停止运行
RealTekWriteREG(&pRealTekReg->reg0w.CR, pRealTekReg, 0x21);
// 延时10 毫秒以上,确保芯片进入停止模式
OSTimeDly(OS_TICKS_PER_SEC >> 4);
// 读取ISR 标志,判断网卡是否复位成功
value = RealTekReadREG(&pRealTekReg->reg0r.ISR, pRealTekReg);
if (value & 0x00000080)
{
printf("NIC Reset OK!\r\n");
}
else
{
printf("NIC Reset Failed!\r\n");
goto InitcleanUp;
}
// 软复位结束
//==========================================
//初始化部分
//==========================================
// 设置发送缓冲区起始地址
RealTekWriteREG(&pRealTekReg->reg0w.TPSR, pRealTekReg, 0x40);
// 设置接收缓冲区范围
RealTekWriteREG(&pRealTekReg->reg0w.PSTART, pRealTekReg, 0x4C);
RealTekWriteREG(&pRealTekReg->reg0w.PSTOP, pRealTekReg, 0x80);
RealTekWriteREG(&pRealTekReg->reg0w.BNRY, pRealTekReg, 0x4C);
// 清除中断标志位
RealTekWriteREG(&pRealTekReg->reg0w.ISR, pRealTekReg, 0xFF);
// IMR 中断屏蔽寄存器,禁止所有中断
RealTekWriteREG(&pRealTekReg->reg0w.IMR, pRealTekReg, 0x00);
// RBCR0, RBCR1 远程字节寄存器,用于设置远程DMA 字节数
RealTekWriteREG(&pRealTekReg->reg0w.RBCR0, pRealTekReg, 0x00);
RealTekWriteREG(&pRealTekReg->reg0w.RBCR1, pRealTekReg, 0x00);
// RCR 接收配置寄存器,监视方式,不接收数据包
RealTekWriteREG(&pRealTekReg->reg0w.RCR, pRealTekReg, 0x20);
// TCR 传输配置寄存器,选择内部Loop back 模式
RealTekWriteREG(&pRealTekReg->reg0w.TCR, pRealTekReg, 0x02);
// DCR 数据配置寄存器,8 位DMA 方式
RealTekWriteREG(&pRealTekReg->reg0w.DCR, pRealTekReg, 0xC8);
// 选择页
RealTekSelectPage(1);
// CURR 当前页面寄存器
RealTekWriteREG(&pRealTekReg->reg1rw.CURR, pRealTekReg, 0x4D);
// MAR0 - MAR7 设置多播地址
RealTekWriteREG(&pRealTekReg->reg1rw.MAR0, pRealTekReg, 0xFF);
RealTekWriteREG(&pRealTekReg->reg1rw.MAR1, pRealTekReg, 0xFF);
RealTekWriteREG(&pRealTekReg->reg1rw.MAR2, pRealTekReg, 0xFF);
RealTekWriteREG(&pRealTekReg->reg1rw.MAR3, pRealTekReg, 0xFF);
RealTekWriteREG(&pRealTekReg->reg1rw.MAR4, pRealTekReg, 0xFF);
RealTekWriteREG(&pRealTekReg->reg1rw.MAR5, pRealTekReg, 0xFF);
RealTekWriteREG(&pRealTekReg->reg1rw.MAR6, pRealTekReg, 0xFF);
RealTekWriteREG(&pRealTekReg->reg1rw.MAR7, pRealTekReg, 0xFF);
// PAR0 - PAR5 设置MAC 地址
RealTekWriteREG(&pRealTekReg->reg1rw.PAR0, pRealTekReg, 0x00);
RealTekWriteREG(&pRealTekReg->reg1rw.PAR1, pRealTekReg, 0x1F);
RealTekWriteREG(&pRealTekReg->reg1rw.PAR2, pRealTekReg, 0x16);
RealTekWriteREG(&pRealTekReg->reg1rw.PAR3, pRealTekReg, 0x16);
RealTekWriteREG(&pRealTekReg->reg1rw.PAR4, pRealTekReg, 0x73);
RealTekWriteREG(&pRealTekReg->reg1rw.PAR5, pRealTekReg, 0x1A);
// 选择页
RealTekWriteREG(&pRealTekReg->reg0w.CR, pRealTekReg, 0x20);
OSTimeDly(OS_TICKS_PER_SEC >> 4);
// RCR 接收配置寄存器,仅接收自己地址的数据包( 以及广播地址数据包) 和多点播送地址包
// 丢弃小于64 字节的数据包,丢弃校验错误的数据包
RealTekWriteREG(&pRealTekReg->reg0w.RCR, pRealTekReg, 0xCC);
// TCR 传输配置寄存器,启用CRC 生成和CRC 自动校验,工作在正常模式
RealTekWriteREG(&pRealTekReg->reg0w.TCR, pRealTekReg, 0xE0);
// 写ISR 寄存器, 清空中断状态寄存器
RealTekWriteREG(&pRealTekReg->reg0w.ISR, pRealTekReg, 0xFF);
// IMR 中断屏蔽寄存器
RealTekWriteREG(&pRealTekReg->reg0w.IMR, pRealTekReg, 0x35);
// 回到正常工作方式
RealTekWriteREG(&pRealTekReg->reg0w.CR, pRealTekReg, 0x22);
当读取ISR和CURR的值的时候,发现两个寄存器都为0xFF,不知为何,请各位赐教,非常感谢!