Storing memory even after power down
dexxterity
Posts: 14
I want to be able to store an array of numbers into EEPROM and have it so even if the power is turned off, when I restore power the array is easily accessable. I think this should be possible, do any of you have ideas on how I can do this? Or maybe a link or explanation on what the spin code would look like. Thanks!
Comments
http://obex.parallax.com/object/12
best regards Stefan
Variables that will change frequently require a bit more consideration that arrays of constants that will not change.
The drawback with storage in the upper eeprom is that reading via I2C, which is a serial mode is rather slow. I have worked with look up tables of over 1000 items in an eeprom and found a lot of time wasted in that approach. But in Forth I could easily change the whole table independent of the program.
Putting the same data in hub ram was much better, faster. If you have a small array (let's say less than 50 items), the fastest place to store it is in cog ram. You can do this in Forth on the Propeller, or in PASM. But these won't preserve variables for reboot that have changed from the original binary.
So you really have three places that you can put an array depending on size and needs for speed, and your need for variables versus constants; but only one if desire it to be unaffected by a reboot, somewhere in the eeprom is best. Several Propeller boards come with 64K eeproms just for this purpose, included the Propeller Quickstart.
In the case of Forth on the Propeller, variables and constants, single or as arrays that are included in the dictionary are in that first 32K. Stays in eeprom for reboot, but is quickly useful from hubram after booting.
Forgive my muddled presentation above.
There is a thread about this in the PEK sticky.
Keep in mind you don't want to write to EEPROM thousands of times a day. The EEPROM will wear out after a bunch of writes. (I don't recall how many a "bunch" is. It could be a million or 100K. It's listed in the datasheet for the EEPROM.)
That link looks like what I need. In the example you linked to how do I enter an address?
The first parameter is the address (of a long), the second is the value to write. As I said, easy-peasy.