英锐恩单片机论坛,Microchip单片机,模拟器件,接口电路,麦肯单片机,单片机应用交流
标题:
如何用C语言编EEPCOM读写?
[打印本页]
作者:
winnie
时间:
2009-4-25 16:11
标题:
如何用C语言编EEPCOM读写?
PIC16F877A的EEPROM
void rd_eeprom()
{ uchar count_rd;
for(count_rd=0X20;count_rd>0;count_rd--)
{ EEADRH=0X20;
EEADR=0X00;
EEPGD=0X00;
RD=0X01;
table[count_rd]=EEDATA;
}
}
void wr_eeprom()
{ uchar count_wr,addr;
addr=0x00;
for(count_wr=0X20;count_wr>0;count_wr--)
{ EEADRH=0X20;
EEADR=addr;
EEDATA=table[count_wr];
EEPGD=0X00;
WREN=0X01;
GIE=0X00;
EECON2=0X55;
EECON2=0X0AA;
WR=0X01;
GIE=0X01;
WREN=0X00;
addr+=1;
}
}
作者:
winnie
时间:
2009-4-25 16:11
有更方便的方法:
gain=read_eeprom(addres);
write_eeprom(addres,data);
欢迎光临 英锐恩单片机论坛,Microchip单片机,模拟器件,接口电路,麦肯单片机,单片机应用交流 (http://enroobbs.com/)
Powered by Discuz! X3.2