24LC256 wrong address at reading


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    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]

  2. #2
    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?

  3. #3
    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

  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

    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.

  5. #5
    Join Date
    Sep 2009
    Posts
    748


    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 : 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