在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]