/************************************************
描述硬件电路:
1,地址连接
P00----A00;(A00-A14:大小为32K)
----------
P07----A07;
P20----A08;
----------
P26----A14;
P10----A15;(A15-A18:为页选择)
----------
P13----A18;
2,控制线连接(EEPROM)
/CE:片选端---接地
/OE:读出信号--接RD(P3.7)
/WE:写入信号--接WR(P3.6)
3.控制线连接(74LS373)
/OE:输出使能端-接地
LE:锁存使能端-接ALE(脚33)
************************************************/
#include <REG668.H>
#include <absacc.h>
#define uchar unsigned char
#define uint unsigned int
#define ulong unsigned long
uchar port_1;
uint port2_port0;
union
{
ulong address_last;
uint address;
uchar c[4];
}a;
uchar table[]={"海"};
uchar data zimo[32];
void delay(count) //crystal=20mz,10MS
{
uchar i,j,k;
for(i=0;i<count;i++)
for(j=0;j<10;j++)
for(k=0;k<200;k++)
;
}
ulong jinei_to_quwei(void)
{
ulong mul_result;
uint dph,dpl;
dph=0;
dpl=0;
mul_result=0;
dph=table[0];
dpl=table[1];
dph=dph-0xa1;
dpl=dpl-0xa1;
mul_result=dph*94+dpl;
return mul_result;
}
void read_eeprom(uchar port1,uint port2_port0)
{
uchar i;
P1=port1;
for(i=0;i<32;i++)
{
zimo[i]=XBYTE[port2_port0+i];//这里是否有错
误??????????????????
}
}
/*****************************************/
void Init_Serial(void)
{
//设置波特率
TMOD=0x20;
TH1=0xf5; //9600HZ
TCON=0x40;
//设置串口
S0CON=0x72;
PCON=0x00;
EA=0;
//启动定时器
TR1=1;
}
void Tran_Data_Pc(char shuju)
{
if(TI==1)
{
TI=0;
S0BUF=shuju;
}
}
/*************************************************/
void main(void)
{
uchar j;
ulong address;
Init_Serial();
address=jinei_to_quwei();
a.address_last=32*address;
port_1=a.c[1];
port2_port0=a.address_last&0x0000FFFF;
read_eeprom(port_1,port2_port0);
while(1)
{
for(j=0;j<32;j++)
{
Tran_Data_Pc(zimo[j]);
delay(10);
}
}
}