winnie 发表于 2009-4-25 16:11:47

如何用C语言编EEPCOM读写?

PIC16F877A的EEPROM
voidrd_eeprom()
{ ucharcount_rd;
for(count_rd=0X20;count_rd>0;count_rd--)
   { EEADRH=0X20;
    EEADR=0X00;
    EEPGD=0X00;
    RD=0X01;
    table=EEDATA;
    }
}
void wr_eeprom()
{uchar count_wr,addr;
addr=0x00;
for(count_wr=0X20;count_wr>0;count_wr--)
   { EEADRH=0X20;
    EEADR=addr;
    EEDATA=table;
    EEPGD=0X00;
    WREN=0X01;
    GIE=0X00;
    EECON2=0X55;
    EECON2=0X0AA;
    WR=0X01;
    GIE=0X01;
    WREN=0X00;
    addr+=1;
   }
}

winnie 发表于 2009-4-25 16:11:54

有更方便的方法:

gain=read_eeprom(addres);

write_eeprom(addres,data);
页: [1]
查看完整版本: 如何用C语言编EEPCOM读写?