void DeeWr(uint16_t addr, uint8_t *dat, uint8_t len)
{
uint8_t xdata *ptr;
uint8_t i;
uint8_t tmp;
ptr = (uint8_t*)addr; //给EEPROM赋值
for(i=0;i<len;i++)
{
ptr[i] = dat[i]; //写eeprom缓存
}
tmp = IE0;
EA = 0; //限时访问不能被中断打扰,操作之前需要保存中断允许位,并关断总中断。
TA = 0xAA; //Open TA
TA = 0x55;
EECON |= 0x01; //Set EECON flag
IE0 = tmp;
while(EECON&0x01); //Wait dee write finished
}
void DeeRd(uint16_t addr, uint8_t *dat, uint8_t len)
{
uint8_t xdata *ptr;
uint8_t i;
ptr = (uint8_t*)addr; //给指针变量赋值
for(i=0; i<len;i++)
{
dat[i] = ptr[i]; //获取eeprom数值
}
}
大家可以相互交流,共同进步,可以加**流也可以加群主微信交流:18665321219
|