Memory dump 24LC16B I2C serial eeprom.
Muttley
Posts: 4
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
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
-Muttley
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.
-Muttley
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).
Try this "Bit Bashing I2C on a BS2"
http://www.lennard.net.nz/electronics/i2c.html
It dumps memory in hex and ascii columns for I2C chips like the 24LC128
Cheers,
Muttley
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.
Jeff T.
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