I think you need to split the address in the I2c command as low and high byte for this to work.
JF
I think you need to split the address in the I2c command as low and high byte for this to work.
JF
Tnx. for fast reply, Jerson! Were you were meaning to send lower and higher address byte separately to EEPROM for reading and writing?
Example:
I2Cwrite DPIN, CPIN, cont, addr.Byte0, [val] 'Writes value to EEPROM address 1
I2Cwrite DPIN, CPIN, cont, addr.Byte1, [val] 'Writes value to EEPROM address 1
In EEPROM datasheet it is described, that the address should be sent in two parts and then data byte. In PICBasic PRO Compiler book it is also written, that address is sent in bytes or words. It is determined by the size of the variable, that is used.
This is what I use to address a 24C512 device
Hope this is what you're looking forCode:I2Cwrite SDA, SCL, $A0, Address.HighByte, Address.LowByte, _ [Date[0],Date[1],Date[2],Time[0],Time[1],Time[2],Key]
JF
I had the same problem with the 24aa eeprom , I had to check the data sheet to find out what the address var should be either byte or word and the make sure the data line and the clock line have pull up resistors,
Good Luck
Mike
P.S. just checked the data sheet quickly and I think the address value should be byte and WC line should be held low during write or the ACK will not be sent..
Last edited by mbruno; - 31st January 2008 at 08:46. Reason: checking the data sheet for information
This address splitting seems logical and I tried it, but unfortunately it didn't change the result. Anyways it remains in my code.
Also I was adding to data line pull up resistor as it was said in datasheet. Now the "val2" value is 16.
In datasheet it is said, that each data byte in the memory has a 16-bit address. The Most Significant Byte should be send first and then Least significant. As I understand the address must be word type variable.
I was checking the routing of reading process. This sequence is a bit different than in writing process.
Read sequence:
Start => Control => Address.HighByte => Address.HighByte => Start => Control => Data Out
Here the Control byte and Start condition has to be send twice. In writing it is without second Start and Control. I don't know how the I2C protocol is set. Perhaps for reading it should be also done something different.
Bookmarks