Shop OBEX P1 Docs P2 Docs Learn Events
Question about storing and retrieving data from EEPROM — Parallax Forums

Question about storing and retrieving data from EEPROM

eiboydeiboyd Posts: 14
edited 2008-01-25 02:46 in Propeller 1
Trying to use the i2c object to do some communication with the 24LC256 EEPROM.
I have written into the eeprom a bunch of bytes in groups of two representing a word.
I read and display the data. This works until mrkr exceeds 255.
Obviously a problem with 8bit something? mrkr is declared as a word.
From reading other i2c posts it appears there is a 256 byte limit? Page? Don't know what that means.
I don't understand what the $A0 is. I know it is the device address (this does not help me)

Is there a document that explains (deviceAddress, deviceRegister, addressbits, databits).
My thought is $A0 can only hold 256 bytes but I don't know where the next address would be?
$A1??????



repeat
     eepromdata.byte[noparse][[/noparse]0]:=i2c.readLocation($A0,mrkr,16,8) 
     waitcnt(clkfreq/200 + cnt) 
     eepromdata.byte:=i2c.readLocation($A0,(mrkr+1),16,8)
     waitcnt(clkfreq/200 + cnt) 
     mrkr := mrkr + 2
     LOOK AT EEPROMDATA





thx

boyd

<subject added by Moderator>

Post Edited By Moderator (Paul Baker (Parallax)) : 1/23/2008 10:34:25 PM GMT

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-01-23 19:45
    What you've described should work. There's no inherent limit of 256 bytes for reading from the EEPROM.
    Are you sure that mrkr is declared as a word? Your problem would make perfect sense if mrkr were declared
    as a byte.

    Download a datasheet for the EEPROM you're using (24LC256). There's a section that describes the meaning of
    each of the bytes transferred from the Propeller to/from the EEPROM including the $A0. You should also read the
    comments in the I2C object.

    The notion of page applies only to writing, not reading. The datasheet goes into detail on this.
  • eiboydeiboyd Posts: 14
    edited 2008-01-23 20:07
    Thanks Mike, I will do some reading from the source you suggest...
    If page stuff refers to writing perhaps therein lies my problem. I write more than 256 bytes.
    The loop below writes 50 two byte datasets three times for a total of 300 bytes (offset by header).

    CON
      header := 7
    PUB
    inc := 0
        repeat 3  
          i2c.writeLocation($A0, 0+header+inc*100, 45, 16, 8)           'FIRST data set
          waitcnt(clkfreq/200 + cnt)
          i2c.writeLocation($A0, 1+header+inc*100, 0, 16, 8)
          
          waitcnt(clkfreq/200 + cnt)                                                  ' 2nd data set
          i2c.writeLocation($A0, 2+header+inc*100, 90, 16, 8)
          waitcnt(clkfreq/200 + cnt) 
          i2c.writeLocation($A0, 3+header+inc*100, 0, 16, 8)
           
          waitcnt(clkfreq/200 + cnt)                                                   ' 3rd data set
          i2c.writeLocation($A0, 4+header+inc*100, 80, 16, 8) 
          waitcnt(clkfreq/200 + cnt)
          i2c.writeLocation($A0, 5+header+inc*100, 0, 16, 8)
    
    ETC...
          
          waitcnt(clkfreq/200 + cnt)                                                    ' 50th data set
          i2c.writeLocation($A0, 98+header+inc*100, 100, 16, 8)
          waitcnt(clkfreq/200 + cnt)
          i2c.writeLocation($A0, 99+header+inc*100, 0, 16, 8) 
          inc := inc + 1
    
    
  • Mike GreenMike Green Posts: 23,101
    edited 2008-01-23 21:22
    If what you posted is what you have in your program, you're missing the WAITCNT after the 100th writeLocation.· You have to wait for the write operation to complete.· It normally takes 5-10ms.· If you don't wait, the EEPROM never sees the next operation.

    Paged writes are not used by writeLocation.· Essentially they let you write a block of data in one 5-10ms write cycle.
    ·
  • eiboydeiboyd Posts: 14
    edited 2008-01-23 21:38
    Doh! I missed the extra wait...

    THX Mike

    I still need to read the documentation, always good to have an understanding...


    boyd
  • SquigSquig Posts: 13
    edited 2008-01-25 00:49
    The thing I don't understand about these chips is how to access addresses past the first 32k.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2008-01-25 00:52
    The 24LC256 is only 32k in size, are you refering to the 128K eeprom on the Hydra or the 64K eeprom on the protoboard?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • deSilvadeSilva Posts: 2,967
    edited 2008-01-25 01:13
    The 24C1024 or 24C1025 do no longer use A0, A1, A2 as pin programmable device address, bit A1 only.
    A0 is used as bit 17, when transmitting the device address.

    I am not aware of specific differences wrt the 24C512...
  • SquigSquig Posts: 13
    edited 2008-01-25 02:08
    Bah, this place I bought mine from had it labeled as 256K not 256kbit.· That explains everything
  • Mike GreenMike Green Posts: 23,101
    edited 2008-01-25 02:46
    That's been true for as long as EEPROMs have been around. They're always labelled in terms of the number of bits, even if they're byte or word organized. Like the 24C1024 is a 1 megabit memory with 128K bytes of EEPROM.
Sign In or Register to comment.