Shop OBEX P1 Docs P2 Docs Learn Events
24lc32 eeprom — Parallax Forums

24lc32 eeprom

Earl FosterEarl Foster Posts: 185
edited 2006-01-21 19:28 in BASIC Stamp
I just received 10 of the 24LC32 EEPROM's for Christmas, along with a bunch of other Parallax electronic goodies, but I don't know how to use them.· I downloaded the data sheet I found in the archieves but I am still confused - I do better by example.· I have looked around and haven't·been able to find·any examples of how to use them in the Stamps in Class series or in Nuts & Volts examples.· Are there any examples available with schemics that show how to use it for external data logging?· If so, can they be posted for downloaded?

Comments

  • cyberbiotacyberbiota Posts: 79
    edited 2005-12-31 00:18
    EBF306-

    Try this thread in the forum:

    http://forums.parallax.com/forums/default.aspx?f=15&m=93373&g=93380#m93380

    peter

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Peter C. Charles

    Director, Research and Technology
    CyberBiota, Incorporated
    Peter.charles@cyberbiota.com
    http://www.cyberbiota.com
  • cyberbiotacyberbiota Posts: 79
    edited 2005-12-31 00:23
    EBF306-

    Or, if you are not using a BS-2P, this might be more helpfull:

    http://forums.parallax.com/forums/default.aspx?f=5&m=2373&g=2388#m2388

    peter

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Peter C. Charles

    Director, Research and Technology
    CyberBiota, Incorporated
    Peter.charles@cyberbiota.com
    http://www.cyberbiota.com
  • kogeratkogerat Posts: 31
    edited 2005-12-31 00:51
    Hi ebf306,

    Check out Stampworks 2, expeiment # 32 I2C communications. You can download Stampworks 2 PDF form here:

    http://www.parallax.com/dl/docs/books/sw/Web-sw-v2.0.pdf

    Hope this helps.

    Jim K
  • Earl FosterEarl Foster Posts: 185
    edited 2005-12-31 03:45
    Thank you
  • Earl FosterEarl Foster Posts: 185
    edited 2006-01-02 19:44
    Thanks again for the great info. After downloading all the different materials and reviewing it I decided to do experiment #32 from the StampWorks 2.0 manual. I get to the initialization section and notice the conditional IF statement about using BS2P or higher. It tells me to use another code SW20-EX32-24LC32-BSP. So now I am stumped.

    First, I thought the I2C commands were only available for BS2P and above?
    And secondly, is SW20-EX32-24LC32-BSP available for download?
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-01-02 20:24
    Native I2C commands are indeed built into the BS2p family, but as that experiment shows you can do I2C on any BS2 module with a bit of code.· And yes, all of the programs are available for download from the product page.

    http://www.parallax.com/detail.asp?product_id=27297

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • kogeratkogerat Posts: 31
    edited 2006-01-02 20:52
    Hi ebf306,

    I assumed you had a BS2. You can do I2C communications with a BS2, but it takes more code than BS2p that has I2C instructions. You can download the source code for the Stampworks 2 experiments·SW20-EX32-24LC32.BS2 and SW20-EX32-24LC32.BSP along with all of the Stampworks 2 source code from here http://www.parallax.com/detail.asp?product_id=27297·at the bottom of the page.

    Sorry for the confusion

    Jim K

    PS, I see Jon beat me to it. Thanks Jon for following up on my less than concise posts!!
  • Earl FosterEarl Foster Posts: 185
    edited 2006-01-20 09:37
    I have been studing and breaking apart the sample programs but I think I am still confused.· So to help me get straight I wrote my own versions and one works and one doesn't.· The first version writes and reads before incrementing the address by 2 bytes.· And the reason why I am jumping 2 bytes is because I have declared the "x" and "y" values to be words which is also the reason why I am using wrdAddr.BYTE1\wrdAddr.BYTE0 directive.

    *********************************************************
    ' {$STAMP BS2p}
    ' {$PBASIC 2.5}

    SCL············PIN···· 1··············' I2C serial clock line
    wrdAddr······VAR···· Word········' word address
    X·············· VAR···· Word········' General purpose variable
    y·············· VAR···· Word······· ' General purpose variable

    wrdAddr = 0·························' Initialize address location
    x = 100
    DO
    ·· I2COUT 0, $A0, wrdAddr.BYTE1\wrdAddr.BYTE0, [noparse][[/noparse]DEC5 x]
    ·· DEBUG HOME
    ·· DEBUG ? x
    ·· DEBUG ? wrdAddr
    ·· I2CIN 0, $A1, wrdAddr.BYTE1\wrdAddr.BYTE0, [noparse][[/noparse]DEC5 y]
    ·· DEBUG ? y
    ·· wrdAddr = wrdAddr + 2
    ·· x = x + 100
    ·· PAUSE 1000
    LOOP UNTIL wrdAddr = 20

    ***********************************************************
    This next one writes properly but reads junk back and I don't understand why.
    ***********************************************************
    ' {$STAMP BS2p}
    ' {$PBASIC 2.5}

    SCL············PIN···· 1··············' I2C serial clock line
    wrdAddr······VAR···· Word········' word address
    X·············· VAR···· Word········' General purpose variable
    y·············· VAR···· Word······· ' General purpose variable

    wrdAddr = 0
    x = 100
    DO······················· ' Works
    ·· I2COUT 0, $A0, wrdAddr.BYTE1\wrdAddr.BYTE0, [noparse][[/noparse]DEC5 x]
    ·· DEBUG HOME
    ·· DEBUG ? x
    ·· DEBUG ? wrdAddr
    ·· wrdAddr = wrdAddr + 2
    ·· x = x + 100
    ·· PAUSE 1000
    LOOP UNTIL wrdAddr = 20
    wrdAddr = 0
    DEBUG CLS
    DO······················ 'Doesn't work
    ·· I2CIN 0, $A1, wrdAddr.BYTE1\wrdAddr.BYTE0, [noparse][[/noparse]DEC5 y]
    ·· DEBUG HOME
    ·· DEBUG ? y
    ·· DEBUG ? wrdAddr
    ·· wrdAddr = wrdAddr + 2
    ·· PAUSE 1000
    LOOP UNTIL wrdAddr = 20
    ***********************************************************


    Can someone straighten me out and tell·what I am doing wrong?
  • Earl FosterEarl Foster Posts: 185
    edited 2006-01-21 01:50
    ok I think I have a better understanding of the 24LC32. It only accepts Bytes. So my question is if I need to record a WORD would I run the I2COUT command twice to capture the data?

    I2COUT 0, $A0, wrdAddr.BYTE1\wrdAddr.BYTE0, [noparse][[/noparse]DEC5 x.byte1]
    I2COUT 0, $A0, wrdAddr.BYTE1\wrdAddr.BYTE0, [noparse][[/noparse]DEC5 x.byte0]

    or could I do

    I2COUT 0, $A0, wrdAddr.BYTE1\wrdAddr.BYTE0, [noparse][[/noparse]DEC5 x.BYTE1, DEC5 x.BYTE0]
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-01-21 07:12
    No, when you use the DEC5 modifier you are sending five bytes. This is one way to store a word-sized variable in the 24LC32, but it's ineffecient as it uses three bytes more than are actually required. Write two bytes: myWord.BYTE0, then myWord.BYTE1. Make sure you read the back in the same order.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Earl FosterEarl Foster Posts: 185
    edited 2006-01-21 15:28
    Thanks Jon. I still don’t understand something that is happening when I go to read the data out of memory. In the first part of my code I am inserting a value of x and displaying the value and memory location on the screen.

    DO
    I2COUT 0, $A0, wrdAddr.BYTE1\wrdAddr.BYTE0, [noparse][[/noparse]x.BYTE0, x.BYTE1]
    DEBUG ? x 'show me the value I am storing
    DEBUG ? wrdAddr 'show me the address location
    x = x + 200 'increment the value of x
    wrdAddr = wrdAddr + 1 'increment to next memory location
    PAUSE 1000 'slow down the read out
    LOOP UNTIL wrdAddr = 5

    This seems to be working properly but when I go to read the values starting at location 0 using this code:

    wrdAddr = $0 'Go back to address 0
    DO
    I2CIN 0, $A1, wrdAddr.BYTE1\wrdAddr.BYTE0, [noparse][[/noparse]x.BYTE0, x.BYTE1]
    DEBUG ? x 'show me the value in memory
    DEBUG ? wrdAddr 'show me the address location
    wrdAddr = wrdAddr + 1 'increment to next memory location
    PAUSE 1000 'slow down the read out
    LOOP UNTIL wrdAddr = 5

    I get completely different values back (37064, 22672, 8280, 59424, 1000). Apparently I am still missing something in my understanding on how to write and read to memory.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-01-21 15:34
    The problem is with your incrementing of wrdAddr -- you need to make it

    · wrdAddr = wrdAddr + 2

    ... as you are writing/reading two bytes. In your current program each write to the EE is clobbering the previous value.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Earl FosterEarl Foster Posts: 185
    edited 2006-01-21 16:24
    Thanks Jon. [noparse]:)[/noparse] Its so obvious once you see it - duh!!
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-01-21 19:28
    Yes, we all have those "smack to the forehead" moments from time-to-time.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.