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>
The board is high speed (6+ghz cpu speed).
please, pretty please reveal which '51 derivative this is. Many of us look for a faster '51 and, evidently, you have fond one.
Or, could it be, that your question is not related to Keil tool which is the only subject this forum is inteded for.
Erik
Its the e80-51 runnnning at the simulation and u try the code on the c51.
static byte[] retrieved_ip8]; static byte[] ip_to_store[8];
I can't imagine that even compiling.
achieving peak processing speeds of up to 300 Mips in ASICs and up to or above 130 Mips in FPGAs an ASIC is out of the question for most and 130MIPS is only 30% better than the best '51 derivatives.
It must have one h... of a clock division to achieve only these MIPS ratings a 6GHz clock.
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.
"I can't imagine that even compiling."
He doesn't say it's C code, though he chose C51 post category. It's Java.
Tsuneo
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.
"It's Java."
static byte[] retrieved_ip8];
Java must accept ']' as part of an identifier, I suppose.
"My eeprom has all it's ce lines tied to something..."
That looks like the problem.
As per the data sheet, you should always connect the ce lines to something else.
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.
As previously noted, the comments mention "TINI", which suggests the Dallas 80C400 (and family) - but then much about that "source code" is open to doubt...
IF it really is Maxim/Dallas, then I'm sure that they must, indeed, have application notes about this...
OP The board is high speed (6+ghz cpu speed).
Andy, I know that Dallas refer to their uCs as "high speed" but they are not that fast.
The OP should be able to give a link to info about his 'cpu'
Well, I did say, "much about that 'source code' is open to doubt" - maybe I should just have said that the entire original post is "open to doubt"...?
The OP seems to have lost interest anyhow...
:-(