Shop OBEX P1 Docs P2 Docs Learn Events
Basic_I2C_Driver SPIN OBJECT and I2C EEPROM — Parallax Forums

Basic_I2C_Driver SPIN OBJECT and I2C EEPROM

TransistorToasterTransistorToaster Posts: 149
edited 2007-11-26 02:26 in Propeller 1
Hello,
I hooked up a second 24lc256 EEPROM with shared I2C lines with the one that has the Propeller code and changed the address on the pin to be a0=1 a1=0 a2=0. I tried using the Basic_I2C_Driver spin object from http://ww1.parallax.com/Support/PropellerLibrary/tabid/65/Default.aspx
obex.parallax.com/objects/26/
and it's not quite working properly.

Now, I thought that the address I was supposed to use is $A0 + 2 = $A2. The two is because of the a0=1 a1=0 a2=0 and in the 24lc256 PDF ww1.microchip.com/downloads/en/DeviceDoc/21203P.pdf page 8, I thought this was right for this type of device on the I2c bus.

Question 1:
What is wrong with my below code? It's not storing and retrieving timeMin and timeHour increments by 1 each time:

...
  long timeDay
  long timeHour
  long timeMin

...
    i2c.Initialize(28)
    eepromStatus:= i2c.ReadPage(28, $A2, 2*(7*60*24)+0 , @timeMin, 1)
''     abort ' an error occured during the write
    eepromStatus:= i2c.ReadPage(28, $A2, 2*(7*60*24)+1 , @timeHour, 1)
''     abort ' an error occured during the write
    eepromStatus:= i2c.ReadPage(28, $A2, 2*(7*60*24)+2 , @timeDay, 1)
''     abort ' an error occured during the write

....code which is not relevant...


       eepromStatus:= i2c.WritePage(28, $A2, 2*(7*60*24)+0 , @timeMin, 1)
''     abort ' an error occured during the write
       eepromStatus:= i2c.WritePage(28, $A2, 2*(7*60*24)+1 , @timeHour, 1)
''     abort ' an error occured during the write
       eepromStatus:= i2c.WritePage(28, $A2, 2*(7*60*24)+2 , @timeDay, 1)





Question 2:
'' CON
''   eepromAddress = $7000



I found this in the SPIN driver itself. What is this for?

Thanks,
Frank

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-11-26 01:24
    1) You have to wait after each WritePage. Look at the example in the comments at the beginning of the I2C driver.

    2) That's part of the sample code. It has nothing to do with the driver itself.
  • TransistorToasterTransistorToaster Posts: 149
    edited 2007-11-26 02:26
    Thanks Mike, all seems to work now.
    Frank
Sign In or Register to comment.