External EEPROM Not getting data (24LC515)


Closed Thread
Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    Tom, I am curently using this part in a project I have designed and it works great. One thing to remember though read the data sheet section on addressing as I had a problem similar to yours and it turned out to be the way they do block switching. Normally this would be done with the external address lines but this part is so big they broke it into 2 blocks. Also make sure all external address lines are tied to +5 or ground. These are the routines I wrote to use this part. I always store by page so as to avoid the accumulated write time associated with this part.

    HTH
    Dave Purola,
    N8NTA

    CNTRL_BYTE CON $A2 'CONTROL BYTE FOR I2C EEPROM MEMORY (A0 USED FOR CHIP SELECT)
    '************************************************* ********************
    RW_EEPROM: 'READ FROM or WRITE TO SERIAL EEPROM
    '************************************************* ********************
    IF BLOCK < 1023 THEN
    IF READ_WRITE = 1 THEN 'WRITE 64 BYTE BLOCK TO EEPROM
    IF BLOCK <> 0 THEN 'IF STARTING NEW PASS DON'T READ OLD LOCATION
    READ_WRITE = 0 'SET FOR BLOCK READ
    GOSUB READ_WRITE_BLK 'READ FROM SERIAL EEPROM NEXT AVAILABLE STORAGE BLOCK
    READ_WRITE = 1 'SET FOR BLOCK WRITE
    ENDIF
    ADDRESS = BLOCK << 6 'CALCULATE 12C ADDRESS TO STORE DATA TO
    CNTROL_BYTE = CNTRL_BYTE 'COPY CONTROL BYTE
    CNTROL_BYTE.3 = ADDRESS.15 'SET 32K BLOCK BIT
    I2CWRITE SDA,SCL,CNTROL_BYTE,ADDRESS,[STR STOR_DATA\64] 'SAVE DATA TO 12C
    PAUSE 6 'ALLOW TIME FOR I2C WRITE ~5Ms.
    BLOCK = BLOCK + 1 'INCREMENT FOR NEXT AVAILABLE BLOCK TO WRITE
    BLOCK = BLOCK MIN 1023 'LIMIT TO 1K BLOCKS OF 64 BYTES
    GOSUB READ_WRITE_BLK 'WRITE TO or READ FROM SERIAL EEPROM LAST STORAGE BLOCK
    ELSE
    ADDRESS = BLOCK << 6 'CALCULATE 12C ADDRESS TO STORE DATA TO
    CNTROL_BYTE = CNTRL_BYTE 'COPY CONTROL BYTE
    CNTROL_BYTE.3 = ADDRESS.15 'SET 32K BLOCK BIT
    I2CREAD SDA,SCL,CNTROL_BYTE,ADDRESS,[STR STOR_DATA\64] 'LOAD IN ENTIRE BLOCK
    ENDIF
    ENDIF
    RETURN

    '************************************************* ********************
    READ_WRITE_BLK: 'WRITE TO or READ FROM SERIAL EEPROM NEXT AVAILABLE STORAGE BLOCK
    '************************************************* ********************
    ADDRESS = 65534 'POINT TO LAST STORED DATA(WORD) ADDRESS
    CNTROL_BYTE = CNTRL_BYTE 'COPY CONTROL BYTE
    CNTROL_BYTE.3 = ADDRESS.15 'SET 32K BLOCK BIT
    IF READ_WRITE = 1 THEN
    I2CWRITE SDA,SCL,CNTROL_BYTE,ADDRESS,[BLOCK.LOWBYTE,BLOCK.HIGHBYTE] 'WRITE DATA POINTER TO 12C
    PAUSE 6 'ALLOW TIME FOR I2C WRITE ~5Ms.
    ELSE
    I2CREAD SDA,SCL,CNTROL_BYTE,ADDRESS,[BLOCK.LOWBYTE,BLOCK.HIGHBYTE] 'READ DATA POINTER FROM 12C
    ENDIF
    RETURN
    Last edited by Dave; - 21st March 2005 at 17:02.

  2. #2
    Join Date
    Feb 2005
    Location
    Bellevue
    Posts
    125


    Did you find this post helpful? Yes | No

    Default Working within 64byte pages

    Thanks for the info. Yes, I was getting messed up with the 'block select' bit - did not realize the 515 was actually 2 x 256, and you have to change this bit to address the rest of the memory.

    Question: My data payload is only 36bytes. I have a page size of 64bytes.. How can I both use the [string] to write pages, and not waste space? Or is it possible?

    Since my payload is 36bytes, if I write a byte at a time, that will take .36 seconds, which is too long. If I write the page, it is what 5ms?

    Thanks,
    TG

Similar Threads

  1. Can't read sequential addresses in external EEPROM
    By tjkelly in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th February 2010, 14:46
  2. Replies: 1
    Last Post: - 28th January 2010, 22:15
  3. Data EEPROM gets clobbered during programming
    By BrianT in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 18th July 2008, 02:46
  4. LCD + bar graph
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 5th October 2005, 14:50
  5. Sinus calculating !
    By Don Mario in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 28th November 2004, 23:56

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts