I2C Addressing problems
Chicago Mike
Posts: 88
I'm having a bit of a problem with my interfacing to an I2C EEPROM (Regardless of model, tried the common 24LC256 and 24LC512), all the results are similar.·Below I have the two modules that are reading and Write respectively, with a bit of trimming. Basicly, the ReadEEPROM will take a LONG value between 1-500, convert it to a bit address and attempt to read that byte, afterreading, it is taking that value (which would be 0-6) and displaying the character listed in the lookupz table.
The write does the same thing, taking an address, and writing at this point a 1 or 2 to the corresponding address. (I haven't made the other cases yet because of the problem that follows). So anyway, easy right? Heres my problem, The read seems to work properly, however the the write is happening one BYTE too high. Hence the result of address 5 is showing up in address 6??
I've commented out my attempt with the "i2cobject" and also tried Mike Greens "Basic_I2C_Driver", with the same results. So I know its sometime I'm doing. My Address math seems right? Any help would be great! Thanks!
PUB ReadEEPROM(Address) | Status, PrintMe
··· Address:=(Address*8)-8
'··· Status := fram.readLocation(Page1, Address, 16, 8)
··· Status:=tester.ReadByte(14, $A0, Address)
··· LCD.MOVE(16,2)
··· PrintMe:= lookupz(Status: String("-"),String("+"),String("1"),String("2"),String("3"),String("4"),String("5"))
··· LCD.str(PrintMe)
Pub WriteEEPROM(Address)
····· Address:=(Address*8)-8
····· case check_buttons
······· iBtnGood:
'········ fram.writeLocation(Page1, Address, 1, 16, 8)
········· tester.WriteByte(14, $A0, Address, 1)·
······· iBtnBad:
'········· fram.writeLocation(Page1, Address, 2, 16, 8)
········· tester.WriteByte(14, $A0, Address, 2)
····· WAITCNT(5_000_000 + CNT)
··
Post Edited (Chicago Mike) : 5/15/2007 5:41:17 PM GMT
The write does the same thing, taking an address, and writing at this point a 1 or 2 to the corresponding address. (I haven't made the other cases yet because of the problem that follows). So anyway, easy right? Heres my problem, The read seems to work properly, however the the write is happening one BYTE too high. Hence the result of address 5 is showing up in address 6??
I've commented out my attempt with the "i2cobject" and also tried Mike Greens "Basic_I2C_Driver", with the same results. So I know its sometime I'm doing. My Address math seems right? Any help would be great! Thanks!
PUB ReadEEPROM(Address) | Status, PrintMe
··· Address:=(Address*8)-8
'··· Status := fram.readLocation(Page1, Address, 16, 8)
··· Status:=tester.ReadByte(14, $A0, Address)
··· LCD.MOVE(16,2)
··· PrintMe:= lookupz(Status: String("-"),String("+"),String("1"),String("2"),String("3"),String("4"),String("5"))
··· LCD.str(PrintMe)
Pub WriteEEPROM(Address)
····· Address:=(Address*8)-8
····· case check_buttons
······· iBtnGood:
'········ fram.writeLocation(Page1, Address, 1, 16, 8)
········· tester.WriteByte(14, $A0, Address, 1)·
······· iBtnBad:
'········· fram.writeLocation(Page1, Address, 2, 16, 8)
········· tester.WriteByte(14, $A0, Address, 2)
····· WAITCNT(5_000_000 + CNT)
··
Post Edited (Chicago Mike) : 5/15/2007 5:41:17 PM GMT
Comments