想编一个51单片机扩展一个外存储卡040的程序,求大神帮忙看看程序有没有错误
因为无论我置CE端选通还是不选通,返回出的结果都是蜂鸣器长鸣,求指点
#include<at89x52.h>
unsigned char xdata Record040[65535]; //定义外部存储器
unsigned char date;
unsigned char address;
void main(void)
{
int i;
unsigned char temp; //返回值
unsigned char Secter;
EA = 0; //关闭所有中断
Secter = 0x00; //扇区
address = 0x0002; //地址
date = 0x00; //数据
P1 = 0xf0; //置CE为0
Record040[0x555] = 0xaa; //写040命令包
Record040[0x2aa] = 0x55;
Record040[0x555] = 0xa0;
P1 = Secter|0x0f; //选择0号扇区
Record040[address] = date; //向address地址写date数据
for(i;i<50000;i++);
temp = Record040[address]; //读address地址中的数据存放在temp
if (temp == date) //判断读出数据是否为写入数据
{
P1_5 = 0; //蜂鸣器长鸣
}
else{
P1_5 = 0;
for(i;i<50000;i++);
P1_5 = 1; //蜂鸣器响1声
}
while(1);
}
因为无论我置CE端选通还是不选通,返回出的结果都是蜂鸣器长鸣,求指点
#include<at89x52.h>
unsigned char xdata Record040[65535]; //定义外部存储器
unsigned char date;
unsigned char address;
void main(void)
{
int i;
unsigned char temp; //返回值
unsigned char Secter;
EA = 0; //关闭所有中断
Secter = 0x00; //扇区
address = 0x0002; //地址
date = 0x00; //数据
P1 = 0xf0; //置CE为0
Record040[0x555] = 0xaa; //写040命令包
Record040[0x2aa] = 0x55;
Record040[0x555] = 0xa0;
P1 = Secter|0x0f; //选择0号扇区
Record040[address] = date; //向address地址写date数据
for(i;i<50000;i++);
temp = Record040[address]; //读address地址中的数据存放在temp
if (temp == date) //判断读出数据是否为写入数据
{
P1_5 = 0; //蜂鸣器长鸣
}
else{
P1_5 = 0;
for(i;i<50000;i++);
P1_5 = 1; //蜂鸣器响1声
}
while(1);
}