24LC256 wrong address at reading


Closed Thread
Results 1 to 14 of 14
  1. #1
    Join Date
    Oct 2012
    Posts
    15

    Default 24LC256 wrong address at reading

    Hello all,
    I wonder if someone can help me with this problem.

    I'm storing manualy some values to 24LC256 with an external programmer and editor like this :

    :020000040000FA ' THis line was from a blank memory - not changed
    :1000000048454C4C4F21FFFF4B4D31375753FF00 'This is the line I edit with my values
    :10001000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0 'All zeros
    :10002000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE0 'All zeros
    ...........continues.......
    :107FF000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF91 'Last line at address 7FF0
    :00000001FF ' THis line was from a blank memory - not changed


    This is text "HELLO!" for address 0 - 5 and text "KM17WS" for address 8 - 13.

    With the following code I'm trying to read the stored text but it seems the address is wrong

    Code:
    addr var WORD
    
    For addr = 0 TO 5                                        '  
    I2CRead memSDA,memSCL,$A1,addr,[STR TEXT\6]     '$A0 does the same as $A1  
    pause 10 
    Next addr
    serout2 lcdp,lcds,[i,line1,"LOC : ",STR TEXT\6]             ' Display TEXT
    With the above code i was expecting to see "HELLO!" but instead i see "M__KM1" !!
    If i change addr values to 3 - 8 then i can see the whole text "KM17WS", but this is supposed to be at locations 8 - 13.
    What am I missing here ?

    PS. There are pullup's to both lines and tried all relative DEFINE's, just in case

    Thank you in advance
    Fanis

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


    Did you find this post helpful? Yes | No

    Default Re: 24LC256 wrong address at reading

    What does the code look like thyat you are using to write the eeprom memory? I think that may be your problem.
    Dave Purola,
    N8NTA
    EN82fn

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: 24LC256 wrong address at reading

    Quote Originally Posted by Fanias View Post
    Hello all,
    I wonder if someone can help me with this problem.

    I'm storing manualy some values to 24LC256 with an external programmer and editor like this :

    Code:
    :020000040000FA                                                ' THis line was from a blank memory - not changed
    :10000000 48 45 4C 4C 4F 21 FF FF 4B 4D 31 37 57 53 FF 00  'This is the line I edit with my values
    >         0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
    :10001000 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF  F0    'All zeros
    >         0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F  cksum
    :10002000 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE0    'All zeros
    ...........continues.......
    :107FF000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF91    'Last line at address 7FF0
    :00000001FF                                                        ' THis line was from a blank memory - not changed
    Fanis
    Looks like you are one byte short on the line you edited. Each line should be 16 bytes plus a checksum. What also looks odd is that the address jumps by
    0x1000 (4k) per line and not 0x10 (16).

    Most good programmers have an editor built in. You would be better off using the editor to change the data and then save it off in a hex format instead of trying to edit the hex file. That way the per line check sum would be correct.
    Last edited by falingtrea; - 6th December 2012 at 19:33. Reason: formatting fix
    Tim Barr

  4. #4
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default Re: 24LC256 wrong address at reading

    One thing I see, is you keep writing over the top of the array "TEXT". Also, you don't need the FOR...NEXT loop to read sequentually.

    Try just this:
    Code:
    I2CRead memSDA,memSCL,$A1,addr,[STR TEXT\14]  'Addr is a WORD, with initial value of $0000
    This will read the first 14 bytes of the array.
    To output try this:
    Code:
    TEXT2   VAR TEXT[8]
    serout2 lcdp,lcds,[i,line1,"LOC : ",STR TEXT\6, "  ",STR TEXT2\6 ]             ' Display

  5. #5
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default Re: 24LC256 wrong address at reading

    One other item. You have this comment: '$A0 does the same as $A1

    I'm assuming this is a reference to the "Control" byte in the command.

    The reason for this, is that the control byte for the EEPROM is $1010XXXR

    The high nibble is $A
    The low nibble is dependent of how the phyical chip select pins are wired. I'm pretty sure you have those either wired to GND or floating. This leaves the two possible values of $A0 or $A1, depending on the last bit. However, the last bit is dependent on whether you are reading or writing, and is controlled by PBP. So, it won't matter what you use there, as long as the 7 MSBs are correct.
    Last edited by SteveB; - 6th December 2012 at 20:23. Reason: typo

  6. #6
    Join Date
    Oct 2012
    Posts
    15


    Did you find this post helpful? Yes | No

    Default Re: 24LC256 wrong address at reading

    Thanks for your comments,

    right now I'm using the built in editor of my PICKIt2 programmer and I make changes.
    It's still the same result, looks to me that I cannot read the first 3 memory addresses (0,1,2) like they don't exist and also I jump 5 addresses ahead, so that address 8 on eeprom can be readed at address 3 with my code.

    I'll try to find another editor for EEPROM hex files, do you have any editor in mind ?

    Fanis

  7. #7
    Join Date
    Oct 2012
    Posts
    15


    Did you find this post helpful? Yes | No

    Default Re: 24LC256 wrong address at reading

    blank_24LC256_eeprom.txt

    I'm trying to upload here a blank hex file for 24LC256. Sorry if I post twice
    If someone can populate addresses 0-5 and 8-13 with data to test with my code, if there is an editing problem by my side.

    blank_24LC256_eeprom.txt



    Quote Originally Posted by Fanias View Post
    Thanks for your comments,

    right now I'm using the built in editor of my PICKIt2 programmer and I make changes.
    It's still the same result, looks to me that I cannot read the first 3 memory addresses (0,1,2) like they don't exist and also I jump 5 addresses ahead, so that address 8 on eeprom can be readed at address 3 with my code.

    I'll try to find another editor for EEPROM hex files, do you have any editor in mind ?

    Fanis

  8. #8
    Join Date
    Oct 2012
    Posts
    15


    Did you find this post helpful? Yes | No

    Default Re: 24LC256 wrong address at reading

    To help you more this is what my programmer shows.
    Name:  24lc256.jpg
Views: 1716
Size:  116.8 KB

    If i try to read addr 3 of EEPROM, I actually read addr 8 and so on....
    So the following command :
    Code:
    I2CRead memSDA,memSCL,$A1,3,[text]
    should read character "B", but instead reads character "K", located at address 8

    What a mess

    Fanis
    Last edited by Fanias; - 6th December 2012 at 21:55. Reason: wrong image

  9. #9
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default Re: 24LC256 wrong address at reading

    Fanis,
    Did you solve the problem?

    Code:
    I2CRead memSDA,memSCL,$A1,3,[text]
    FYI, the "3" here is a constant, and is going to cause problems, since the 24LC256 needs a WORD addr.

    try:

    Code:
    addr VAR WORD:addr=3
    I2CRead memSDA,memSCL,$A1,addr,[text]

  10. #10
    Join Date
    Oct 2012
    Posts
    15


    Did you find this post helpful? Yes | No

    Default Re: 24LC256 wrong address at reading

    Hi Steve and thank you for your interest,
    I did what you suggested and it works, however it's still not working when "addr" is in a For-next loop.
    I get the same results, maybe I'm missing something in front of my eyes.
    What i mean is that if i use the code in my first message (for addr = 0 to 5, where addr var word) I jump eeprom positions.
    It drives me crazy, so I'll not spend more time on this, I have modified my code and will go that way with some more lines of code.

    However, if anyone ever finds why this is happening, I would like to know
    Thank you all for your answers and interest.

    Fanis

    Quote Originally Posted by SteveB View Post
    Fanis,
    Did you solve the problem?

    Code:
    I2CRead memSDA,memSCL,$A1,3,[text]
    FYI, the "3" here is a constant, and is going to cause problems, since the 24LC256 needs a WORD addr.

    try:

    Code:
    addr VAR WORD:addr=3
    I2CRead memSDA,memSCL,$A1,addr,[text]

  11. #11
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default Re: 24LC256 wrong address at reading

    Code:
    addr var WORD
    
    For addr = 0 TO 5                                        '  
    I2CRead memSDA,memSCL,$A1,addr,[STR TEXT\6]     '$A0 does the same as $A1  
    pause 10 
    Next addr
    Lets look at what this is doing. First, let's start with what's in the EEPROM. Starting at Address $00 (I put _ as placeholders for the value $FF):

    Code:
                0123456789ABCDEF
    $0000-000F: HELLO!__KM17WS__
    The 1st time through the loop, addr = 0, the PIC sets the register address in the 24LC256 to $0000, then reads 6 bytes sequentially, and puts them into TEXT = "HELLO!"
    The 2nd time through the loop, addr = 1, the PIC sets the register address in the 24LC256 to $0001, then reads 6 bytes sequentially, and puts them into TEXT = "ELLO!_"
    The 3rd time through the loop, addr = 2, the PIC sets the register address in the 24LC256 to $0002, then reads 6 bytes sequentially, and puts them into TEXT = "LLO!__"
    ...
    The 6th time through the loop, addr = 5, the PIC sets the register address in the 24LC256 to $0005, then reads 6 bytes sequentially, and puts them into TEXT = "!__KM1"

    At least that's the way it should be working. I'm not sure why you got "M__KM1".

    However, now hopefully you see why, when you changed the FOR...NEXT loop to count from 3 to 8, it gave you "KM17WS"

    It's because on the last loop addr = 8, the register address set in the 24LC256 is $0008, then it reads 6 bytes sequentually, and you end up with TEXT = "KM17WS"

    That help?

  12. #12
    Join Date
    Oct 2012
    Posts
    15


    Did you find this post helpful? Yes | No

    Wink Re: 24LC256 wrong address at reading

    Quote Originally Posted by SteveB View Post
    Code:
    addr var WORD
    
    For addr = 0 TO 5                                        '  
    I2CRead memSDA,memSCL,$A1,addr,[STR TEXT\6]     '$A0 does the same as $A1  
    pause 10 
    Next addr
    Lets look at what this is doing. First, let's start with what's in the EEPROM. Starting at Address $00 (I put _ as placeholders for the value $FF):

    Code:
                0123456789ABCDEF
    $0000-000F: HELLO!__KM17WS__
    The 1st time through the loop, addr = 0, the PIC sets the register address in the 24LC256 to $0000, then reads 6 bytes sequentially, and puts them into TEXT = "HELLO!"
    The 2nd time through the loop, addr = 1, the PIC sets the register address in the 24LC256 to $0001, then reads 6 bytes sequentially, and puts them into TEXT = "ELLO!_"
    The 3rd time through the loop, addr = 2, the PIC sets the register address in the 24LC256 to $0002, then reads 6 bytes sequentially, and puts them into TEXT = "LLO!__"
    ...
    The 6th time through the loop, addr = 5, the PIC sets the register address in the 24LC256 to $0005, then reads 6 bytes sequentially, and puts them into TEXT = "!__KM1"

    At least that's the way it should be working. I'm not sure why you got "M__KM1".

    However, now hopefully you see why, when you changed the FOR...NEXT loop to count from 3 to 8, it gave you "KM17WS"

    It's because on the last loop addr = 8, the register address set in the 24LC256 is $0008, then it reads 6 bytes sequentually, and you end up with TEXT = "KM17WS"

    That help?
    You make me feel stupid , but I forgive you it's always good to learn something new.
    My mistake is clear about the use of the STR modifier, however can you help me with the I2cwrite command ?

    Code:
    Addr=0
    I2cwrite memsda,memscl, $a0, addr, [str text\5]
    The above is not working or maybe STR is only used at "read" commands ?
    This works for me instead :

    Code:
    I2cwrite, memsda, memscl, $a0, addr, [text[0], text[1],......, text[4]]
    A big thanks
    Fanis

  13. #13
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default Re: 24LC256 wrong address at reading

    Quote Originally Posted by Fanias View Post
    You make me feel stupid , but I forgive you
    Sorry, didn't mean to come across that way, just wanted to make sure my explanation was clear.


    Quote Originally Posted by Fanias View Post
    Code:
    Addr=0
    I2cwrite memsda,memscl, $a0, addr, [str text\5]
    The above is not working or maybe STR is only used at "read" commands ?
    This works for me instead :

    Code:
    I2cwrite, memsda, memscl, $a0, addr, [text[0], text[1],......, text[4]]
    Not sure why [STR TEXT\5] didn't work, it should have.

  14. #14
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default Re: 24LC256 wrong address at reading

    There must be pause 5ms after writing before next operation.

Similar Threads

  1. Reading from External Hex Address...
    By sbouda in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 30th October 2008, 06:33
  2. Eeprom 24lc256
    By chip_select in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 23rd March 2008, 19:19
  3. Programming IC2 24LC256
    By Squibcakes in forum General
    Replies: 12
    Last Post: - 20th September 2006, 14:36
  4. 24LC256 and PIC16F877
    By Tomas in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 1st March 2004, 13:01
  5. Writing / Reading EEPROM 24LC256 Problem
    By schmoddel in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 27th February 2004, 18:55

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