SDA=1; //STOP

delay();

}

2.这是一个读写24C系列EEPROM的程序,已经经过本人亲自测试,通过!!!!!

//*************************************

//** M2401,M2402,M2404,M2408,M2416,M2432,M2464,M24128,M24256

//** 21c01,24c02:1010A2A1A0R/W; 24C04:1010A2A1P0R/W; 24C08:1010A2P1P0R/W

//** 24C16:1010P2P1P0R/W; //** 以上6种芯片的读写格式为:start-device addr-ack-first word addr-ack-second word addr-ack-data-ack-stop

//** 进行读写的字节数,EEPROM首址,EEPROM控制字节,

//** 以及EEPROM类型。此程序结构性良好,具有极好的容错性,程序机器码也不多:

//** 以上5种芯片的读写格式为:start-device addr-ack-word addr-ack-data-ack-stop

//** 24c32-24c512:1010A2A1A0R/W; 24C1024:1010A2A1P0R/W; 24c1024:1010A2A1P0R/W //** 通用的24C01-24C1024共11种EEPROM的字节读写操作程序,

//**************************24C01读写的c51源程序***********************************

#i nclude

#i nclude

#i nclude

#i nclude

sbit SDA =P1^1;

sbit SCL =P1^4;

sbit WP =P1^7;

sbit light =P1^0;

sbit power =P1^6;

#define uchar unsigned char

#define uint unsigned int

void iic_delay10ms();

void iic_delay(void);

void iic_start(void);

void iic_stop(void);

void iic_ack(void);

void read_byte(void);

void send_byte(void);

void initial(void);

void ok(void);

void error(void);

void read_eeprom(void);

void write_eeprom(void);

void init(void);

uchar ack_flag,send_data,receive_data[32];

uchar rw,type,device_addr,addr[3],num;

void main(void)

{

initial();

power =0;

light =0;

while(1)

{

ES =1;

rw =0x55;

WP =0;

while(rw ==0x55);