Shop OBEX P1 Docs P2 Docs Learn Events
Memory dump 24LC16B I2C serial eeprom. — Parallax Forums

Memory dump 24LC16B I2C serial eeprom.

MuttleyMuttley Posts: 4
edited 2011-12-02 19:04 in BASIC Stamp
Hello,

I have been reviewing all related material regarding reading and writing to a 24LC16B serial eeprom via I2C. But the examples I have seen simply write and read to the eeprom (using a specific address). I have a need to "dump" the contents of a 24LC16B to a terminal screen for review. I am working on a data logger project using a Basic Stamp 2. Can anyone point me in the proper direction or provide a link to an example program that will sequentially read an eeprom in its entirety an display the contents?

Thank you for your assistance and time.

-Muttley

Comments

  • MuttleyMuttley Posts: 4
    edited 2011-11-29 05:04
    Wow, I was told that the Parallax forums were the place to go for help. Not even one soul can assist me with this query? I have reviewed all the other posts by Jon Williams and others but am still confused. I simply need to 'dump' the memory contents of a 24LC16B sequentially to a debug terminal. The 24LC16B is an external (not the one on the stamp) IC with the necessary 4.7K ohms pull up resistors. The example programs I have looked at simply do a random write and then a random read. This is not what I am looking for hence my query. I have scoured the internet sites and the entire Parallax support site for a solution with no success. All the examples I have found are variations on the same random write and random read program found on this site. I have attempted to 'modify' one of these programs to do what I am looking for and was met with utter failure. Please, can someone at least point me in the proper direction? I have both the BS2 and BS2p40 to work with. Thank you very much. I appreciate anyones input.

    -Muttley
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2011-11-29 05:59
    Hi, the Basic Stamp Syntax and Reference Manual at this link http://www.parallax.com/Store/Books/BASICStamp/tabid/168/ProductID/143/List/0/Default.aspx?SortField=ProductName,ProductName

    has a very good description and schematic that will work with your BS2p40 using I2C commands starting on page 218.

    See if you can get part or all to work and then if you need additional help post back here.

    Jeff T.
  • MuttleyMuttley Posts: 4
    edited 2011-11-29 06:08
    Thank you very much Unsoundcode. I am reading this now. I appreciate your reply.

    -Muttley
  • Mike GreenMike Green Posts: 23,101
    edited 2011-11-29 07:41
    The reason all the code you've found just does random reads and writes is that it's the basic example. If you're writing some other kind of program, being able to read and write a single arbitrary location is, in the end, what you need to be able to do. I had seen your question earlier and, because I didn't have the specific kind of program you wanted, I didn't reply hoping someone else might have what you wanted. You're probably going to have to write it yourself using the pieces you've found so far. It's not that complicated. You just have to read the 2K bytes of the EEPROM, one at a time. You probably want to group them 8 or 16 per line with the address displayed at the beginning of the line. You use the HEX formatter (see the Stamp Manual for details) to display the values in hexadecimal. Here's a rough sketch ....

    addr = 0 ' start at beginning
    for line = 1 to 128 ' 128 lines of 16 each
    debug hex4 addr
    for item = 1 to 16
    gosub readEEPROM ' read a byte at addr, result in value
    debug " ", hex2 value
    addr = addr + 1
    next item
    debug CR
    next line

    The readEEPROM routine depends on whether you're using a BS2 or BS2p. There is a Nuts and Volts Column (#115 ?) that shows subroutines for I2C access that essentially duplicate the functionality for the BS2 that's built into the I2C statements on the BS2p.

    If you ask for ready-to-go code that no one has, you may wait a long time for an answer. If you ask for advice on how you might do something, you'll usually get a much faster answer, but you'll have to do some of the work yourself. If you ask some obscure or unusual question, you may also have to wait a while for someone who knows something about your subject to notice. There is a lot of expertise here, just not necessarily when you want it (usually right away).
  • john_sjohn_s Posts: 369
    edited 2011-11-29 09:00
    @Muttley,

    Try this "Bit Bashing I2C on a BS2"

    http://www.lennard.net.nz/electronics/i2c.html
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2011-11-29 10:47
    Here is some code for a BS2 you might find helpful.
    It dumps memory in hex and ascii columns for I2C chips like the 24LC128
  • MuttleyMuttley Posts: 4
    edited 2011-12-02 01:01
    Thank you all for your replies. I've been busy with the holidays fast approaching. I am still struggling to get a grip of this issue. I am left so confused by the datasheets and the way the stamps handle external EEPROMS. I thought that this would be so simple to accomplish but yet the answers seem so far away. I have a better understanding of how to do the sequential EEPROM reading via an 18F4550 PIC. The applications notes for PIC microcontrollers are really informative. However, the stamps don't require me to learn C++ or assembly language to program them. I am quite familiar with BASIC and feel comfortable programming with it. I find C++ syntax confusing and assembly langauge extremely daunting. But, in the end it may be the way to go if I can get over the learning curve. I am still wondering why this is so difficult to achieve using the Parallax Basic Stamps. I truly thought it would be easier than this. I do appreciate all of you who responded to this query. Seems like every time I start a project I run into these sort of problems. Perhaps blinking LEDS are all that I am supposed to be able to do. Time will tell.


    Cheers,
    Muttley
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2011-12-02 02:46
    Even the Parallax Forums slow down around the holidays - people have more active social lives and are traveling to meet family and friends.

    Microchip does indeed have a lot of nice Application Notes that are helpful with any microcontroller. On the other hand, Parallax has put a huge amount of time into publishing the Basic Stamp Manual which is free in download form. I don't know what I'd do without a copy.

    Regarding I2C eeproms, they generally have two modes of operation. The simplest reads one address at a time without any buffering. The second alternative can read up to 16 bytes serially and requires a 16 byte buffer to smoothly transfer a block of data.

    We all have a bit of trouble reading manufacturer's PDF sheets, but the learning curve eventually flattens as we learn the concepts and the terminology. Learning to use them is really a necessary rite of passage for an electronics hobby in today's world.

    So if you want to create fast, efficient EEPROM reads and writes - you need to plan loops that increment an address index either one address at a time or in an increment of 16 or less bytes.

    And, there is a delay involve in when the EEPROM is ready for the next Write - this can be handled simply by adding a wait or a verification routine. If you want to verify large blocks of data, Checksum calculations are best. You create a Checksum for the block you want to transfer and after the transfer, you read and compile a 2nd checksum to compare with the original. If it doesn't match, you rewrite the whole block until it does or opt out with a Write Aborted message.

    http://en.wikipedia.org/wiki/Checksum

    CRC (Cyclic Redundancy Check) algorithms are likely the most appropriate forms of checksum for small EEPROMs.

    http://en.wikipedia.org/wiki/Cyclic_redundancy_check

    You have several choices, but some are just more reliable with 8 bit data. Those are the ones you should consider as the EEPROM is storing a byte at a time -- CRC-8 format.
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2011-12-02 05:42
    Hi Muttley, which Stamp are you using or would prefer to use and what code do you have so far. If we can see the code its much easier to give direction.

    Jeff T.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-12-02 19:04
    24C04_demo_100%.bs2
    Here's a program based on Jon WIlliams's work that I modified for another member a few years ago.
    It's for a 24C04. It's commented well enough.
    It writes a number to two different addresses and then DEBUGs those.
    The eeprom has to be set up as '00' (or modify for your address of choice
Sign In or Register to comment.