winnie 发表于 2009-4-25 15:28:23

PIC16F877的片内eeprom写入和读取问题

eeprom_wt(unsigned char address,unsigned char data)//片内EEPROM的写操作
{
EEADR=address;
EEDATA=data;
EEPGD=0;
WREN=1;
GIE=0;
EECON2=0x55;
EECON2=0xaa;
WR=1;
GIE=1;//允许全局中断
WREN=0;//写保护
EEIF=0;
do{;}
while(EEIF==0);
}
unsigned char eeprom_rd(unsigned char address)//片内EEPROM的读取
{
unsigned char rd_data;
EEADR=address;
EEPGD=0;
RD=1;
rd_data=EEDATA;//读取EEDATA的内容
return(rd_data);
}

winnie 发表于 2009-4-25 15:28:40

调用PIC。H里的库函数即可
调用PIC。H

eeprom_read(Adress);

eeprom_write(Adress,temp1);
                while(!EEIF)asm("clrwdt");
页: [1]
查看完整版本: PIC16F877的片内eeprom写入和读取问题