Shop OBEX P1 Docs P2 Docs Learn Events
eeprom problems : fm24C16A-P — Parallax Forums

eeprom problems : fm24C16A-P

ionion Posts: 101
edited 2004-08-19 16:35 in BASIC Stamp
I am using an eeprom on my project and I found out some strange behaviors.
Some how , data written to a location with i2cout was written to multiple locations, at 256 bytes interval.
To test , I just put one i2cout command to address 0, value =1234, then I read all 2047 locations with a loop.
The sample code is at the end.
When I look at debug screen I can see at address 0,256,512 and so on ·,the read values was 1234.
What I do wrong ? I tried to replace the eeprom, with some other brand new one· ( I bought 10), and the result is the same. I spoke with the eeprom manufacturer Ramtron,
http://www.ramtron.com/ and they told me that is nothing wrong with the chip, the problem is how i2cout handle the protocol.
I need help please .
Thank you
·
' {$STAMP BS2pe}
' {$PBASIC 2.5}
' {$PORT COM2}
·
·
new········ VAR···· Word
addr······· VAR···· Word
VALUE······ VAR···· Word
·
VALUE=· 1234
·
·I2COUT 0, $A0, 0, [noparse][[/noparse]DEC4 value]
·DEBUG "DONE",CR
·
PAUSE 1000
Read_From_EEPROM:
· FOR addr = 0 TO 2047
I2CIN 0,$A1,ADDR, [noparse][[/noparse]HEX4· new]
··· DEBUG "Addr: " ,DEC4 addr, "·· ",
········· "READ: ", HEX4 new,CR
· ADDR=ADDR+3
· NEXT
· END
·
This is the short form of debug screen. I deleted the lines with 0000 in between

DONE
Addr: 0000·· READ: 1234
Addr: 0004·· READ: 0000
·
Addr: 0252·· READ: 0000
Addr: 0256·· READ: 1234
Addr: 0260·· READ: 0000
·
Addr: 0508·· READ: 0000
Addr: 0512·· READ: 1234
Addr: 0516·· READ: 0000
·
Addr: 0764·· READ: 0000
Addr: 0768·· READ: 1234
Addr: 0772·· READ: 0000
·
Addr: 1020·· READ: 0000
Addr: 1024·· READ: 1234
Addr: 1028·· READ: 0000
·
Addr: 1276·· READ: 0000
Addr: 1280·· READ: 1234
Addr: 1284·· READ: 0000
·
Addr: 1532·· READ: 0000
Addr: 1536·· READ: 1234
Addr: 1540·· READ: 0000
·
Addr: 1788·· READ: 0000
Addr: 1792·· READ: 1234
Addr: 1796·· READ: 0000

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-08-18 20:19
    The problem is how you're using I2COUT and I2CIN.· You have a device that requires two-byte syntax, but you're using one-byte syntax -- so your I2CIN statement is rereading the same 256-byte block.· You can fix your program with the correct syntax:

    I2COUT 0, $A0, addr.BYTE1\addr.BYTE0, [noparse][[/noparse]DEC4 value]
     
    I2CIN 0, $A1, addr.BYTE1\addr.BYTE0, [noparse][[/noparse]HEX4 new]
    
    


    When in doubt, consult the Help file -- it will show you the correct syntax and examples for using it.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • ionion Posts: 101
    edited 2004-08-18 21:08
    Thank you Jon for the prompt reply. I tested the sample in the help file with the address 2050 and works fine. My question, is how I am sure that the "value" was not written to an other address. I know there is a sample program in the help, which I looked at it many times, but the syntax is too high for a beginner. What kind of simple loop to use to read the whole chip? And the second aspect is : Do I have to manually calculate the address by dividing with 256 every time·? What I do for example for address 12 or 159 ?
    I still do not understand the mechanism of this i2c command. I thought that it will be simple to write i2cout and just put the location and the software will deal with low and high bytes.
    Can you please send me a link where I can find more to read for a beginner. I have a nice collection of stamps books from Parallax, 6 or 7 but I did not find the answer to my question.
    Thank you
    Ion
    ·
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-08-18 21:33
    Our help file samples are meant to be as simple as possible without hiding the details of commands.

    You can rerun your test program with the corrected syntax I showed you above and you should see that it is now correct. Here's how I would write it (using Parallax programming standards):

    ' {$STAMP BS2pe} 
    ' {$PBASIC 2.5} 
    ' {$PORT COM2} 
    
    
    
    testVal    VAR    Word
    eeAddr     VAR    Word
     
     
    Setup:
      eeAddr = 0
      testVal = 1234
      I2COUT 0, $A0, eeAddr.BYTE1\eeAddr.BYTE0, [noparse][[/noparse]DEC4 testVal]
     
    Main:
      DO
        I2CIN 0, $A1, eeAddr.BYTE1\eeAddr.BYTE0, [noparse][[/noparse]DEC4 testVal]
        DEBUG DEC4 eeAddr,  " : ", DEC4 testVal, CR
        eeAddr = eeAddr + 4
      LOOP WHILE (eeAddr < 2048)
      END
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office


    Post Edited (Jon Williams) : 8/18/2004 9:41:18 PM GMT
  • ionion Posts: 101
    edited 2004-08-18 21:44
    jon,

    here is the sample modified, but the result is the same.

    new VAR Word

    addr VAR Word

    VALUE VAR Word

    addr= 10

    VALUE= 1234


    I2COUT 0, $A0, addr.BYTE1\addr.BYTE0, [noparse][[/noparse]DEC4 value]
    ''I2COUT 0, $A0, 0, [noparse][[/noparse]DEC4 value]

    DEBUG "DONE",CR



    PAUSE 1000

    Read_From_EEPROM:

    FOR addr = 0 TO 2047

    ''I2CIN 0,$A1,ADDR, [noparse][[/noparse]HEX4 new]
    I2CIN 0, $A1, addr.BYTE1\addr.BYTE0, [noparse][[/noparse]DEC4 new]

    DEBUG "Addr: " ,DEC4 addr, " ",

    "READ: ", DEC4 new,CR

    ADDR=ADDR+3

    NEXT

    END

    Wher i am wrong?
    Thanks
    Ion
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-08-18 21:46
    You may have written that data with bad code earlier. Write a little program that puts zero in every address, then run the other test. I don't have the device you're using, so I can't test the code myself.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • ionion Posts: 101
    edited 2004-08-18 21:49
    Sorry jon,

    What i got on your answer just few minutes ago it is completly diferent then what i see now. Initialy it was my pieces of code, and now i see it is changed. Please disregard the previous reply

    Thanks

    IOn
  • WorapohtWorapoht Posts: 17
    edited 2004-08-19 12:53
    coded you are talking to for 24C164 (can have more than 1 device per bus)
    not 24C16 which partitioned to 8 pages of 256byte !
    you may seen on datasheet that slave address not just $A0,
    but $A2/$A4/$A6/$A8,$AC and $AE also used too..
    is %1010 follow with A2 A1 A0 R/W..

    then read code section should to be

    Read_From_EEPROM:
    FOR addr = 0 TO 2047
    I2CIN 0,$A1+((addr/256)<<1),(ADDR//256), [noparse][[/noparse]HEX4 new] ' modified code here
    DEBUG "Addr: " ,DEC4 addr, " ",
    "READ: ", HEX4 new,CR
    ADDR=ADDR+3
    NEXT
  • ionion Posts: 101
    edited 2004-08-19 16:35
    Thank you for explanation.
    I will read the manual or data sheet more carefuly
    Thanks again
    Ion
Sign In or Register to comment.