首先,我们要编写一个读写8019寄存器的函数
/*****************************************************************************************************
//函数名:void writeRegister(uint8 address,uint8 val)
//描述 :
//参数 :
//返回 :
//其他 :
******************************************************************************************************/
void writeRegister(uint8 address,uint8 val)
{
uint8 temp;
uint8 addr;
temp = address;
temp &= 0x1f; //only 5 bits
/*
addr = (~temp);
IO0SET= (IO0SET & 0xff00ffff) | (temp<<16);
IO0CLR = (IO0CLR & 0xff00ffff) | (addr<<16);*/
addr = (~temp)& 0x1f;
IO0SET= (IO0SET & 0xffe0ffff) | (temp<<16);
IO0CLR = (IO0CLR & 0xffe0ffff) | (addr<<16);
//output data
IO1DIR |=0x00ff0000;
//IO1SET |= val<<16;
//IO1CLR |= (~val)<<16;
addr = (~val);
IO1SET = (IO1SET & 0xff00ffff) | (val<<16);
IO1CLR= (IO1SET & 0xff00ffff) | (addr<<16);
//active write
IO0CLR |=RTL8019_W;
IO0CLR |=RTL8019_RDY;
IO0SET |=RTL8019_RDY;
IO0SET |=RTL8019_W;
IO1SET |=0x00ff0000;//IOCON;
}
RTL的寄存器分为4页,可以通过设定CR(command Register)的PS1 PS0 来选择.
/*****************************************************************************************************有了这3个函数,我们就只需要对RTL8019的寄存器进行设置就可以了.就是说,剩下的工作就是进行配置.下面有个比较典型的配置.
/*****************************************************************************************************
//函数名:void netInit(void)
//描述 :
//参数 :
//返回 :
//其他 :本程序参考过www.laogu.com ,zlg的TCP/IP,想对程序进行更深入的了解可以到他们的网站获取
********************************************************************************************************/
void netInit(void)
{
HardWareInit();
delayMs(200);
writeRegister(0x1f,0x00);
delayMs(200);
writeRegister(0x00,0x21);//stop net card
delayMs(200);
PageSelect(0);
writeRegister(0x0a,0x00);
writeRegister(0x0b,0x00);
writeRegister(0x0c,0xe0);//RCR
writeRegister(0x0d,0xe2);//TCR
PageSelect(0);
writeRegister(0x01,0x4c);//PStart
writeRegister(0x02,0x80);//PStop
writeRegister(0x03,0x4c);//Bnry
PageSelect(0);
writeRegister(0x04,0x40);//TPSR
writeRegister(0x07,0xff);//clear intrrput bit
writeRegister(0x0f,0x11);
//writeRegister(0x0e,0xcb);
writeRegister(0x0e,0xc8);///8bits DMA
PageSelect(1);
writeRegister(0x07,0x4d);//CURR
writeRegister(0x08,0x00);
writeRegister(0x09,0x00);
writeRegister(0x0a,0x00);
writeRegister(0x0b,0x00);
writeRegister(0x0c,0x00);
writeRegister(0x0d,0x00);
writeRegister(0x0e,0x00);
writeRegister(0x0f,0x00);
writeRegister(0x00,0x22);
writeMAC(NetPort[0].My_Mac);
PageSelect(0);
writeRegister(0x0c,0xcc);
////RCR 1 1 MON PRO AM AB AR SEP
//bit.5 MON = 1 这只检查地址,不存入缓冲
//bit.4 PRO = 1 所有包的目标MAC地址都接收
//bit.3 AM = 1 接收目标地址为组播地址
//bit.2 AB = 1 接收目标地址为广播地址
//bit.1 AR = 1 长度小于64字节的也接收
//bit.0 SEP = 1 包有接收错误也接收
writeRegister(0x0d,0xe0);
writeRegister(0x00,0x22);
//writeRegister(0x0f,0xff);//IMR
writeRegister(0x07,0xff);
}
经过这样的配置以后,连接上网络看到接收的LED在闪烁,说明已经可以接收到网络上的数据.下面要做的就是把数据从8019的ram中读入来.
用户30174 2010-4-28 14:31
请问我下载过来.用KEIL打开.怎么遍译一下.说显示错误啊!~!~
用户166625 2009-12-21 21:08
用户36438 2009-12-5 18:28
用户834906 2009-9-15 18:15
chunyangjs_567602352 2009-2-5 00:33
用户1033464 2006-11-4 23:32
很想知道您的硬件是怎么连的,想搞清楚如何模拟ISA总线。
多谢赐教!