Loading ...
Sorry, an error occurred while loading the content.

I2C eeprom sequence read problem

Expand Messages
  • erik89us
    Hello guys, In my last topic about I2C i couldn t get my 24C02 eeprom working correctly, after some struggling and the help of a friendly jallist user(Shawn
    Message 1 of 2 , Mar 1, 2007
    • 0 Attachment
      Hello guys,

      In my last topic about I2C i couldn't get my 24C02 eeprom working
      correctly, after some struggling and the help of a friendly jallist
      user(Shawn Standfast) i got it working correctly. Now i got it up and
      running i was trying to add the sequenceread function specified in
      the datasheet: http://www.tranzistoare.ro/datasheets/90/80437_DS.pdf .

      The datasheet specifies that after each datablock you must place
      another
      acknowledgement to read the upcoming datablock. My goal was to read 8
      bytes in 1 action so i changed the old read command from:


      procedure eeprom_read(byte in icaddress, byte in addresslow, byte out
      data) is
      i2c_put_write_address( icaddress )
      i2c_put_data( addresslow )
      i2c_wait_ack()
      i2c_put_read_address( icaddress )
      i2c_get_data( data )
      i2c_put_nack
      i2c_put_stop
      end procedure


      To:

      procedure eeprom_pageread(byte in icaddress, byte in addresslow, byte
      out d0, byte out d1, byte out d2, byte out d3, byte out d4, byte out
      d5, byte out d6, byte out d7) is
      i2c_put_write_address( icaddress )
      i2c_put_data( addresslow )
      i2c_wait_ack()
      i2c_put_read_address( icaddress )
      i2c_get_data( d0 )
      i2c_wait_ack()
      i2c_get_data( d1 )
      i2c_wait_ack()
      i2c_get_data( d2 )
      i2c_wait_ack()
      i2c_get_data( d3 )
      i2c_wait_ack()
      i2c_get_data( d4 )
      i2c_wait_ack()
      i2c_get_data( d5 )
      i2c_wait_ack()
      i2c_get_data( d6 )
      i2c_wait_ack()
      i2c_get_data( d7 )
      i2c_put_nack
      i2c_put_stop
      end procedure


      The piece of code i'm using for reading all of that is:

      for 15 loop
      eeprom_pageread(chipaddress, addressL, val0, val1, val2, val3,
      val4, val5, val6, val7)
      eeprom_put(teller, val0)
      teller = teller + 1
      eeprom_put(teller, val1)
      teller = teller + 1
      eeprom_put(teller, val2)
      teller = teller + 1
      eeprom_put(teller, val3)
      teller = teller + 1
      eeprom_put(teller, val4)
      teller = teller + 1
      eeprom_put(teller, val5)
      teller = teller + 1
      eeprom_put(teller, val6)
      teller = teller + 1
      eeprom_put(teller, val7)
      teller = teller + 1
      addressL = addressL + 8
      end loop


      The problem is that each time it loops it only reads the first byte
      and the rest is ignored. So if the eeprom contains 1,2,3,4,5,6,
      7,8,9,10,11,12,13,14,15,16

      and i issue my command i get the following returned:

      1, FF, FF, FF, FF, FF, FF, FF
      9, FF, FF, FF, FF, FF, FF, FF

      I almost can't understand why this shouln't work as it looks so
      simple in the datasheet and modifying the code looks even simpler.
      There's only 1 issue i can think of and that is because of the eeprom
      is very old ( 15 years ). Maybe the 24C02's of that timeframe didn't
      support sequencereading or something like that? In anyway.

      My old topic which contains the information and links which you may
      need is contained here:

      http://tech.groups.yahoo.com/group/jallist/message/23325

      Thanks in advance.

      Greets,

      Erik
    • Vasile Surducan
      ... jallist ... and ... http://www.tranzistoare.ro/datasheets/90/80437_DS.pdf . ... read 8 ... out ... byte ... out ... The following code is quite curious for
      Message 2 of 2 , Mar 5, 2007
      • 0 Attachment
        --- In jallist@yahoogroups.com, "erik89us" <gswwarlord@...> wrote:
        >
        > Hello guys,
        >
        > In my last topic about I2C i couldn't get my 24C02 eeprom working
        > correctly, after some struggling and the help of a friendly
        jallist
        > user(Shawn Standfast) i got it working correctly. Now i got it up
        and
        > running i was trying to add the sequenceread function specified in
        > the datasheet:
        http://www.tranzistoare.ro/datasheets/90/80437_DS.pdf .
        >
        > The datasheet specifies that after each datablock you must place
        > another
        > acknowledgement to read the upcoming datablock. My goal was to
        read 8
        > bytes in 1 action so i changed the old read command from:
        >
        >
        > procedure eeprom_read(byte in icaddress, byte in addresslow, byte
        out
        > data) is
        > i2c_put_write_address( icaddress )
        > i2c_put_data( addresslow )
        > i2c_wait_ack()
        > i2c_put_read_address( icaddress )
        > i2c_get_data( data )
        > i2c_put_nack
        > i2c_put_stop
        > end procedure
        >
        >
        > To:
        >
        > procedure eeprom_pageread(byte in icaddress, byte in addresslow,
        byte
        > out d0, byte out d1, byte out d2, byte out d3, byte out d4, byte
        out
        > d5, byte out d6, byte out d7) is
        > i2c_put_write_address( icaddress )
        > i2c_put_data( addresslow )
        > i2c_wait_ack()
        > i2c_put_read_address( icaddress )
        > i2c_get_data( d0 )
        > i2c_wait_ack()
        > i2c_get_data( d1 )
        > i2c_wait_ack()
        > i2c_get_data( d2 )
        > i2c_wait_ack()
        > i2c_get_data( d3 )
        > i2c_wait_ack()
        > i2c_get_data( d4 )
        > i2c_wait_ack()
        > i2c_get_data( d5 )
        > i2c_wait_ack()
        > i2c_get_data( d6 )
        > i2c_wait_ack()
        > i2c_get_data( d7 )
        > i2c_put_nack
        > i2c_put_stop
        > end procedure
        >
        >
        > The piece of code i'm using for reading all of that is:

        The following code is quite curious for me.


        > for 15 loop
        > eeprom_pageread(chipaddress, addressL, val0, val1, val2,
        val3,
        > val4, val5, val6, val7)

        here you've read sequentially the eeprom according to fig7-3 from
        the previous datasheet, and you've did it 15 times right ? why ?

        and below you're writting (the same eeprom?) byte by byte with the
        value readed...

        How will you know the problem is on reading or on writting ?
        Do you have a scope and could check the acknowledge after every byte
        readed in the page read mode ?

        > eeprom_put(teller, val0)
        > teller = teller + 1
        > eeprom_put(teller, val1)
        > teller = teller + 1
        > eeprom_put(teller, val2)
        > teller = teller + 1
        > eeprom_put(teller, val3)
        > teller = teller + 1
        > eeprom_put(teller, val4)
        > teller = teller + 1
        > eeprom_put(teller, val5)
        > teller = teller + 1
        > eeprom_put(teller, val6)
        > teller = teller + 1
        > eeprom_put(teller, val7)
        > teller = teller + 1
        > addressL = addressL + 8
        > end loop
        >
        >
        > The problem is that each time it loops it only reads the first
        byte
        > and the rest is ignored. So if the eeprom contains 1,2,3,4,5,6,
        > 7,8,9,10,11,12,13,14,15,16
        >
        > and i issue my command i get the following returned:
        >
        > 1, FF, FF, FF, FF, FF, FF, FF
        > 9, FF, FF, FF, FF, FF, FF, FF
        >
        > I almost can't understand why this shouln't work as it looks so
        > simple in the datasheet and modifying the code looks even simpler.
        > There's only 1 issue i can think of and that is because of the
        eeprom
        > is very old ( 15 years ). Maybe the 24C02's of that timeframe
        didn't
        > support sequencereading or something like that? In anyway.
        >
        > My old topic which contains the information and links which you
        may
        > need is contained here:
        >
        > http://tech.groups.yahoo.com/group/jallist/message/23325
        >
        > Thanks in advance.
        >
        > Greets,
        >
        > Erik
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.