根据安装目录下的demo,
void write(void) // write a byte of data to EEPROM
{
GIE=0; // disable interrupts
WREN=1; // enable writes
EECON2=0x55; // required sequence for EEPROM update
EECON2=0xAA;
WR=1;
while(WR)continue;
EEIF=0;
WREN=0;
GIE=1; // re-enable interrupts
}
自己做了个测试函数:
Init_eeprom(void)
{
EECON1 &= ~0xc0; //选择操作eeprom数据存储区
}
//
void Test_ee(void)
{
char data = 0;
EEADR = 0x00;
EEDATA=0x20;
write();
//data=read();
//Disp_char(data);
}
发现eeprom的数据没有写进去,0XFF.
没发现那里不妥,请知情者指教啊 |