winnie 发表于 2009-4-27 14:38:49

在C程序设计中实现对EEPROM的读写

//EEPROM读函数
uchar EEPROMREAD(uchar addr)
{
uchar data;
GIE = 0;
CLRWDT();
NOP();
NOP();
data = eeprom_read(addr);
GIE = 1;
return data;
}
//EEPROM写函数
void EEPROMWRITE(uchar addr,uchar data)
{
uchar data2;
while(1)
{
CLRWDT();
GIE = 0;
data2 = eeprom_read(addr);
GIE = 1;
if(data2 == data) return;
GIE = 0;
eeprom_write(addr,data);
GIE = 0;
DelayMs(1);
}
}
页: [1]
查看完整版本: 在C程序设计中实现对EEPROM的读写