Dear,
I ame trying programming a st eeprom M24LR16Ehttp://www.google.fr/url?sa=t&rct=j&q=M24LR16E&source=web&cd=2&cad=rja&ved=0CC4QFjAB&url=http%3A%2F%2Fwww.st.com%2Finternet%2Fcom%2FTECHNICAL_RESOURCES%2FTECHNICAL_LITERATURE%2FDATASHEET%2FDM00031737.pdf&ei=aixbUM2iA6mg0QXw2oHoCA&usg=AFQjCNGlQFduFRDRPHq5eYOdAtwnh9R6tw memory on my arduino uno.
The code of the device right connected on the A4 and A5 pin of the arduino is : 1010 111 R/W.
memory is structured in sector and memory slot are numeroted from 0 to 2048 => So 16-bits adress format.
So the 7bit adress is 0x57. Doesn't it ?
To write data on the chip, according to the datasheet, I need.
- Starting the communication
- Sending the 7-bits adres
- sending the 1 bit read/write : 1 to read, 0 to write
- Sending the adress (and the data)
I think it is a classical but, I can't read/write anything
My code is like that
#include <Wire.h>
void M24LR16E_read(int adress){
Wire.beginTransmission(0X57);
Wire.write((int)(adress >> 8)); // MSB
Wire.write((int)(adress & 0xFF));
Wire.endTransmission();
Wire.requestFrom(0X57,1);
int c = 0;
for ( c = 0; c < 1; c++ ){
if (Wire.available()){
Serial.print(Wire.read());}
}
}
void M24LR16E_write(int adress){
int ad=2304;
Wire.beginTransmission(0x57);
Wire.write((int)(adress >> 8)); // MSB
Wire.write((int)(adress & 0xFF));
Wire.write((byte)0xFF);
Wire.endTransmission();
}
void setup(){
Wire. begin();
Serial.begin(9600);
}
void loop(){
M24LR16E_write(0);
delay(10);
M24LR16E_read(0);
Serial.print("....\n\r");
delay(10);
}
Any idea about how read/write correctly in this chip ?
Regards,
GM
Edit: I have 2 10K ohm pull-up resistors on sda and scl. I work with 5 V dc.