24LC256 Serial EEPROM


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2005
    Posts
    11

    Default 24LC256 Serial EEPROM

    The 24lc256 has a page size of 64 bytes i am trying to input the values 0 to 63 into the eeprom and then pull them out again into a different array.
    Cannot seem to get it right cant read the full 64 bytes the last byte reads 0 or 255 What am i doing wrong here?
    Cheers.
    ADCON1.3 = 0
    ADCON1.2 = 1
    ADCON1.1 = 1
    ADCON1.0 = 0

    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2
    Define LCD_DREG PORTD
    Define LCD_DBIT 0
    Define LCD_RSREG PORTE
    Define LCD_RSBIT 0
    Define LCD_EREG PORTE
    Define LCD_EBIT 1
    Define LCD_RWREG PORTE
    Define LCD_RWBIT 2


    COUNTERx var byte[63]
    COUNTERy var byte[63]
    ADDR VAR WORD
    X VAR byte
    Y VAR byte

    LET ADDR = $0000

    for Y = 0 to 63
    COUNTERX[Y] = Y
    NEXT Y

    PAUSE 1000

    i2cwrite PORTD.4,PORTD.5,$A000,ADDR,[STR COUNTERX\64]


    PAUSE 1000



    PAUSE 50
    Lcdout $FE,1
    LCDOUT "TEST"
    LCDOUT $FE,$C2,"TEST"

    PAUSE 1000
    LET ADDR = $0000

    I2CREAD PORTD.4,PORTD.5,$A000,ADDR,[STR COUNTERY\64]
    PAUSE 2000

    FOR X = 0 TO 63
    LCDOUT $FE,1
    LCDOUT #COUNTERY[X]
    PAUSE 500
    NEXT X

    end

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    For a start you've only defined 63 byte Arrays... and then you try to read 64 bytes into it! Try...

    COUNTERx var byte[64]
    COUNTERy var byte[64]

    Whilst arrays are numbered starting from ZERO, the definition has to contain the actual size... because...

    COUNTERx var byte[0]

    ... is an illegal definition as you've defined ZERO elements for the array... so you need to define at least one element...

    COUNTERx var byte[1]

    ...in order to access COUNTERx(0).

  3. #3
    Join Date
    Dec 2005
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    Hi Melanie
    Thanks will try it.

  4. #4
    Join Date
    Dec 2005
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    Hi,
    Also i found that i was sending a two byte control code which was displacing the array elements ($A000) it should have been $A0

    Thanks all is working as expected.
    Last edited by TonyCNC; - 15th December 2005 at 04:15.

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. 24c16 vs 24lc256 and serial wire identification
    By inspired4real in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 14th October 2008, 17:37
  3. How to write/read strings EEPROM/LCD
    By g-hoot in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 11th February 2007, 06:26
  4. Pic16F628A and 24LC256 EEPROM I2C
    By Mike96 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 1st January 2006, 03:13
  5. word variable to 25lc640
    By TONIGALEA in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 6th July 2004, 19:59

Members who have read this thread : 1

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