We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi all I am struggling to the my 24c02 eeprom talking over i2c. I have a custom board with the eeprom on p1.0/p1.1 pins. The board is high speed (6+ghz cpu speed). My eeprom has all it's ce lines tied to something, so the address should be 50h. When I run my app, I think the eeprom is being selected as I get no error when I use 50h but get errors on other addresses. So I think my device select is ok but I cannot read/write to the device. Can all you guru's please see what I have done wrong? Thanks a lot.
static byte[] retrieved_ip8]; static byte[] ip_to_store[8]; static byte[] data[8]; static byte[] result[8]; static void get_IP(I2CPort meeprom) { try(errortrap); { // Read the i2c eeprom. if (meepromread(data,0,2) < 0) { printfln("Failed to read ip address from i2c eeeprom.\n"); return; } else { meepromwrite((byte) 0xa1 }, 0 ,1); //read mode Byte b = null; meepromread(data,0,1); b = Byte(data[0]); print("Data : " + b); } } errorit(DoItToMe) { printn("Illegal Address on Memory mapped I2C"); return; } } static void write_IP(I2CPort meeprom) { try { //write the hex value 0x03 to the i2c eeprom. if ((meepromwrite((byte) 0xa0, (byte) 0x03 }, 0 ,2)) < 0) { println("Failed on write command"); return; } println("Write part 1 of ip address to i2c eeprom."); } { println("Illegal Address on Memory mapped I2C"); return; } } static void read_meeprom() { // Set up I2C driver parameters // This uses the default pins P1.0(SDA) and P1.1(SCL) I2CPort meeprom = I2CPort(); eepromslaveAddress = (byte)0x50; //the slave address we want to read from. meepromsetClockDelay((byte)10); //may need to adjust this delay based on our TINI speed.??? System("Getting IP from I2C eeprom."); get_IP(meeprom); Systemprintln(); } static void write_meeprom() { // Set up I2C driver parameters // This uses the default pins P1.0(SDA) and P1.1(SCL) I2CPort meeprom = I2CPort(); meepromslaveAddress = (byte)0x50; //the slave address we want to write to. meepromsetClockDelay((byte)10); //may need to adjust this delay based on our TINI speed.??? println("Writing IP to I2C eeprom."); write_IP(meeprom); println(); } static void main(String[] *args) { println("I2C Memory Tester"); println("-----------------"); write_meeprom(); println("Sleep 100ms between read and write."); sleep(100); read_meeprom(); } } </code>
Are you clocking the EEPROM too fast?
How do the signal look on the scope?
Your code in not formated correctly and hard to read see "Tips for Posting Messages".
Is this hardware or software I2C?
Did you follow the write directions in the Data sheet?
If you can it is easier if you use a preprogramed EEPROM to test reads. Then you can be sure if it is a read or write issue.
Is this hardware or software I2C? which begs the question: which '51 derivative does the OP use on his "custom board"
The obvious and easy solution would, of course, be to use a derivative with hardware IIC, since virtually all derivatives with HW IIC has appnotes or such with all needed code.
I am an ardent advocate of hardware IIC simply because the overhead of bit-banging is so huge.
Erik