好文档 - 专业文书写作范文服务资料分享网站

AT89C51ED2 的EEPROM 读写

天下 分享 时间: 加入收藏 我要投稿 点赞

AT89c51ED2 EEPROM程序:

#include \# include \

unsigned char w_dat[10]={1,2,3,4,5,6,7,8,9,0}; unsigned char r_dat[10];

unsigned char R_EEPROM_BYTE(unsigned int addr) {

bit ea_temp;

unsigned char dat;

while((EECON&0x01)!=0);//EEBUSY = 0? 等待 ea_temp = EA; EA=0;

EECON = 0x02; //EEE=1; 使能EEPROM dat = XBYTE[addr]; EECON= 0x00; EA=ea_temp; return dat; }

void R_EEPROM_nBYTE(unsigned int saddr,unsigned char num, unsigned char *s) {

unsigned char i; for(i=0;i

s[i]=R_EEPROM_BYTE(saddr++); } }

void W_EEPROM_BYTE(unsigned int addr ,unsigned char dat) {

bit ea_temp;

while((EECON&0x01)!=0); ea_temp=EA; EA = 0;

EECON = 0x02; // EEE=1; XBYTE[addr]=dat; EECON = 0x00; EA = ea_temp; }

void W_EEPROM_nBYTE (unsigned int saddr,unsigned char num, unsigned char *s ) {

unsigned char i;

for(i=0;i

void main() {

while(1) {

W_EEPROM_nBYTE(0x0000,10 ,w_dat);

R_EEPROM_nBYTE(0x0000,10, r_dat); } }

AT89C51ED2 的EEPROM 读写

AT89c51ED2EEPROM程序:#include\#include\unsignedcharw_dat[10]={1,2,3,4,5,6,7,8,9,0};unsignedcharr_dat[10];unsignedcharR_EEPROM_BYTE(unsignedintaddr){b
推荐度:
点击下载文档文档为doc格式
8rent2cbv66bod04q705
领取福利

微信扫码领取福利

微信扫码分享