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>
It's Java.
Not sure about that. It looks more like Java than C, but I don't think any Java compiler would accept the OPs code!
I think he's taken Java code and tried to convert it to C. When I say tried, I mean it in a loose sense.
The other givaway is in a comment where the word TINI is given - The only place I've ever seen that is when talking about the Dallas 80C400 (and family) that has a Java interpreter package.