Shop OBEX P1 Docs P2 Docs Learn Events
Question about memory — Parallax Forums

Question about memory

computer guycomputer guy Posts: 1,113
edited 2010-01-05 02:22 in Propeller 1
I need to be able to save over 100 variables in memory that can be changed post programming, and have it retain the value after a loss of power.
In the past I have changed the value of the variable on the EEPROM the propeller is using however due to constant reading and writing this method will age the EEPROM rapidly, something I can't afford to do in this project.

Is there another way that I can save "settings" to memory and have them last a loss of power?



Thank you smile.gif

-Anthony

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"powered by Propeller" domed stickers $1.50 - Find them here
Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net

Comments

  • MacGeek117MacGeek117 Posts: 747
    edited 2010-01-04 23:15
    Due to the fact that the Prop operates with RAM, you'll have to stick with using the EEPROM for the settings.
    You could put a small EEPROM (24C32) on the same bus as the boot EEPROM.
    MacGeek

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    BS2: $49


    SX48 Protoboard: $10

    Propeller Protoboard: Priceless

    www.apple.com

    www.parallax.com

    www.goldmine-elec.com

    www.expresspcb.com

    www.jameco.com
  • computer guycomputer guy Posts: 1,113
    edited 2010-01-04 23:21
    Thank you MacGeek117,

    last time I used the EEPROM I referenced the starting address of the variable (@var1) to overwrite the value.
    If I was to use a second EEPROM on the same bus, how would I read and write variables?


    Thank you smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "powered by Propeller" domed stickers $1.50 - Find them here
    Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net
  • Mike GreenMike Green Posts: 23,101
    edited 2010-01-04 23:44
    You should consider using a Ramtron FRAM instead of EEPROM for your application. This is a different sort of non-volatile memory that is sold as an EEPROM replacement and can be directly substituted for an EEPROM like the Prop's boot EEPROM. It comes in sizes up to 64K bytes with a standard I2C interface. Although it can "wear out" like EEPROM, the number of cycles quoted are 3 to 4 orders of magnitude greater. Read cycles are destructive, so the data is automatically written back to the memory array after a read. This counts as a write cycle, but the practical lifetime of the device is much longer than most real-world equipment even with this. Using a FRAM would allow you to use the same technique that you used before without worrying about "wear out".
  • computer guycomputer guy Posts: 1,113
    edited 2010-01-04 23:47
    Thank you Mike.
    I would also like to save on EEPROM space if possible, so I like the idea of a second EEPROM or FRAM.

    Is there a simple way of reading and writing data to this second chip?


    Thank you smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "powered by Propeller" domed stickers $1.50 - Find them here
    Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net
  • mctriviamctrivia Posts: 3,772
    edited 2010-01-04 23:48
    If you are likely to do more then 1,000,000 writes to the variable then you will want to use NVRAM or battery backed up RAM. Unlike EEPROM these will not wear out. Many RTC chips have a battery backed up RAM area you can use.

    However you can often reduce writes by first checking if the value there is already equal to what you want to write or by having a large cap and a brown out system that will warn you to write all important variables to eeprom before the power goes out.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    24 bit LCD Breakout Board now in. $21.99 has backlight driver and touch sensitive decoder.
  • computer guycomputer guy Posts: 1,113
    edited 2010-01-05 00:00
    Thank you mctrivia.
    I am using the rtc chip that parallax sells for my project, however I would rather not use this as I will be constantly reading the time (once or twice every second).
    Another reason that I wan't to keep it on a seperate chip is that with my last project, every time I updated the "firmware" on my project, the variables would go back to their default value.


    Thank you smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "powered by Propeller" domed stickers $1.50 - Find them here
    Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net
  • localrogerlocalroger Posts: 3,452
    edited 2010-01-05 00:04
    The RamTron solution would work, but a 64Kbyte or 128Kbyte FRAM costs more than the Prop.

    Another approach is to use the upper half of a 64K EEPROM but only a chunk at a time.· You don't want to use an EE location counter because that will wear out in 500K cycles (I've seen EE do this so it is no lie).· But you can say, all unused EE in the upper half will be 0xFF except for the block that's in use, which will always start with 0x00.· When the Prop boots search the upper half of EE·for this marker, and create it if it doesn't exist.· Then, whenever you save changes, write the new values to the next possible location, wrapping around when you hit the end of the upper half,·and write the old values in the old location to 0xFF.· If you need 128 bytes of status, this will increase your EE life expectancy from 500K to 500K * 32K / 128 or over 120,000,000 cycles.· In many applications that can be the difference between periodic field replacement and de facto permanence.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-01-05 01:41
    The same routines that you'd use to write to the boot EEPROM will also work for any other EEPROM attached to the Prop. It's easiest if you just connect SCL and SDA in parallel and set the address select bits of the 2nd EEPROM to something other than all to ground. The easiest I/O driver to use is the "Basic I2C Driver" in the Object Exchange. This automatically assumes that each EEPROM occupies 64K out of a possible 512K address space, so addresses from $10000 to $1FFFF will select the EEPROM with address select bits %001 and addresses from $70000 to $7FFFF will select the EEPROM with address select bits %111.
  • computer guycomputer guy Posts: 1,113
    edited 2010-01-05 02:12
    Thank you Mike, however with my previous usage I already had the variables defined in SPIN as
    VAR
    long     powersave
    
    


    and then I could change it using some code to overwrite the current data in EEPROM by referencing the start address
    @powersave
    
    



    If the variables aren't predefined in SPIN, how do I reference them?


    Thank you smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "powered by Propeller" domed stickers $1.50 - Find them here
    Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net
  • Mike GreenMike Green Posts: 23,101
    edited 2010-01-05 02:22
    During your initialization routine, you read them in from whereever you put them in the EEPROM. It's not as convenient as them just appearing in the "right place", but it works. The EEPROM I/O driver has read routines just like it has write routines.
Sign In or Register to comment.