Shop OBEX P1 Docs P2 Docs Learn Events
need help to read an entire 16k eeprom — Parallax Forums

need help to read an entire 16k eeprom

ionion Posts: 101
edited 2004-09-18 21:44 in BASIC Stamp
I need help to check the data stored in a 24LC16B eeprom.
I know there is an example on the help file, but is not exactly what I want.
I need to read this chip from location· 0 to the end and display in a debug windows· in the format ·DEC4, CR ·the numbers stored on it. I have the feeling that I have wrong data in some places.
All the locations store decimal numbers no ASCII. Lets say as example, at the beginning I have stored 1234 from the location 0. At location 2 and 3 I have 5678, and so on until the end.
Can somebody give me a clue how to read the entire chip. What is the magic formula in a kind of loop from start to end. I can read individual location, but I have no idea how to make a general syntax to read all locations.
Thanks
Ion

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-09-18 19:06
    If you're using a BS2p/BS2pe you can do it like this:

    Test:
    · FOR wrdAddr = 0 TO 2047
    ··· slvAddr = $A0 | (wrdAddr.BYTE1 << 1)
    ··· I2CIN 0, slvAddr, wrdAddr.BYTE0, [noparse][[/noparse]regValue]
    ··· DEBUG DEC4 wrdAddr, TAB, DEC3 regValue, CR
    · NEXT

    Keep in mind that all locations in the 24LC16B are bytes (0 - 255), so to store words (16-bits, 0 - 65535) you need to use two bytes. If you're reading back words, you could do it like this (assuming words are stored in the 24LC16B in "little endian" mode):

    Test:
    · FOR wrdAddr = 0 TO 2047 STEP 2
    ··· slvAddr = $A0 | (wrdAddr.BYTE1 << 1)
    ··· I2CIN 0, slvAddr, wrdAddr.BYTE0, [noparse][[/noparse]value.BYTE0, value.BYTE1]
    ··· DEBUG DEC4 wrdAddr, TAB, DEC5 value, CR
    · NEXT

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • ionion Posts: 101
    edited 2004-09-18 19:24
    Thanks for helping me again
    Ion
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-09-18 19:47
    Oops, after rereading your post I may have missed something. Did you write to the chip using DEC4 format? If so, here's how you can get the information back:

    Test:
    · FOR wrdAddr = 0 TO 2047 STEP 4
    ··· slvAddr = $A0 | (wrdAddr.BYTE1 << 1)
    ··· I2CIN 0, slvAddr, wrdAddr.BYTE0, [noparse][[/noparse]DEC4 value]
    ··· DEBUG DEC4 wrdAddr, TAB, DEC4 value, CR
    · NEXT

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • ionion Posts: 101
    edited 2004-09-18 21:44
    Solved my question. This version works.
    Thanks
    Ion
Sign In or Register to comment.