Mazen21
Junior Member level 1
Hello,
I need to save some data in a 24LC256 eeprom from a pic, the eeprom work with I2C.
I linked the sda and the scl pin with 2 pull up resistor of 4.7kohm, linked the 3 pins A0 A1 and A2 with the ground.
The eeprom then has the address of 0XA0 for read and 0XA1 for write. This is the PIC program, I'm using a 16F887 with 20mhz crystal:
I think I did it all but The simulation in proteus ISIS always shows me that I'm reading 255.
Please any suggestion and Ideas.
Thanks
I need to save some data in a 24LC256 eeprom from a pic, the eeprom work with I2C.
I linked the sda and the scl pin with 2 pull up resistor of 4.7kohm, linked the 3 pins A0 A1 and A2 with the ground.
The eeprom then has the address of 0XA0 for read and 0XA1 for write. This is the PIC program, I'm using a 16F887 with 20mhz crystal:
Code:
unsigned char i = 0;
char txt[4];
void rc(){
uart1_write(10);
uarT1_write(13);
}
void main(){
uart1_init(9600);
I2C1_Init(100000);
I2C1_Start();
I2C1_Wr(0xA0);
delay_ms(10);
I2C1_Wr(0x00);
delay_ms(10);
I2C1_Wr(0x00);
delay_ms(10);
I2C1_Wr(10); //donnée à écrire
delay_ms(10);
I2C1_Stop();
Delay_100ms();
I2C1_Start();
I2C1_Wr(0xA1);
delay_ms(10);
I2C1_Wr(0x00);
delay_ms(10);
I2C1_Wr(0X00);
delay_ms(10);
I2C1_Repeated_Start();
I2C1_Wr(0xA1);
delay_ms(10);
i=I2C1_Rd(0);
I2C1_Stop();
bytetostr(i,txt);
uart1_write_text(txt);
rc();
}
Please any suggestion and Ideas.
Thanks