51單片機片外擴展RAM
{
0,1,2,3,4,5,6,7,8,9,
10,11,12,13,14,15,16,17,18,19,
20,21,22,23,24,25,26,27,28,29,
30,31,32,33,34,35,36,37,38,39,
40,41,42,43,44,45,46,47,48,49,
50,51,52,53,54,55,56,57,58,59,
60,61,62,63,64,65,66,67,68,69,
70,71,72,73,74,75,76,77,78,79,
80,81,82,83,84,85,86,87,88,89,
90,91,92,93,94,95,96,97,98,99
};
//延時ms函數(shù):
void Delayms(unsigned int t)
{
unsigned int i,j;
for(i=t;i>0;i--)
for(j=120;j>0;j--);
}
//主函數(shù):
int main(void)
{
unsigned char i;
oe=0;//使能RAM芯片片選和地址鎖存器
for(i=0;i100;i++)
XBYTE[300+i]=ramdata[i];
//將100個數(shù)據(jù)寫入片外RAM,起始地址為:300
while(1)
{
for(i=0;i100;i++)
{
P1=XBYTE[300+i];//從片外RAM讀取數(shù)據(jù),點亮P1口的8個LED
Delayms(500);
}
}
return 0;
}
評論