我用MEGA168PA做EEPROM试验,读数据可以,写数据不行不行,望哪位高手指点一下,谢谢!
uchar eeprom_read(uint addr)
{
while(EECR & (1 << EEPE));
EEAR = addr;
EECR|=(1<<EERE);
return EEDR;
}
uchar eeprom_write(uint addr,uchar date)
{SREG|=0x0;
while(EECR & (1 << EEPE));
EEAR = addr;
EEDR=date;
EECR|=(1<<EEMPE);
EECR|=(1<<EEPE);
SREG|=0x80;
} |