Go Down

Topic: I2C EEPROM dump? (Read 4 times) previous topic - next topic

rarick123

Here's an example of what I'm looking at:

Code: [Select]

#include <Wire.h>
#define EEPROM_ADDR 0x50

void setup(){
 Wire.begin();
 Serial.begin(9600);

 int rdata = 33;
 Wire.beginTransmission(EEPROM_ADDR);
 Wire.send(0x00); // MSB
 Wire.send(0x00); // LSB
 Wire.send(rdata);
 Wire.endTransmission();
 Serial.println(rdata);

 Wire.beginTransmission(EEPROM_ADDR);
 Wire.send(0x00);
 Wire.send(0x00);
 Wire.endTransmission();
 Wire.requestFrom(EEPROM_ADDR,1);
 if (Wire.available()) Serial.println(Wire.receive());
}
void loop(){
}


From what I can tell, this should open the I2C bus, move the address pointer to the first memory block, and write either the decimal value "33" or the ASCII equivalent "!" to that space. My understanding from the datasheet for the 24LC16B is that the pointer increments by 1 after every operation, so the next little piece moves back to 0x0000 and does a read. I would expect that the read would come back with either the 33 or the ! as well, but I get nothing. My serial monitor shows the 33 on one line, and that unprintable square character on the second line.

rarick123

Something's tripping me up... the sample code on the Playground for setting the address pointer looks like this:

Code: [Select]

 Wire.send((int)(eeaddress >> 8)); // MSB
 Wire.send((int)(eeaddress & 0xFF)); // LSB


If I do some basic math and set "eeaddress" to 1023, the above lines would send "3" and "255" to the I2C bus. Should it be sending "255" for the LSB, or should it be sending "FF"? Something more like this:

Code: [Select]

 Wire.send(eeaddress >> 8, HEX); //MSB
 Wire.send(eeaddress & 0xFF, HEX); //LSB



Delta

I tested this only a week ago, not only does it work, but even with WP enabled you can send write commands to the chip....just nothing gets written.

Waffle

Quote
If I have write protect enabled, is it still possible to update the internal address pointer?

I haven't tested it myself, however it should still work.

rarick123

That's a great help, thank you! I did have one question about the WP pin though... If I have write protect enabled, is it still possible to update the internal address pointer?

Go Up