Shop OBEX P1 Docs P2 Docs Learn Events
IC2 to The P1 EPPROM — Parallax Forums

IC2 to The P1 EPPROM

I want to write a couple of my variables to the epprom, so on boot up after a power cycle the veritable will retain their value. I have seen a few discussion talk about doing a write @your_variable_name but I'm not sure what the best object for that is. Can someone give me some pointers? Thanks in advance!

Comments

  • I don't know if it's "best," but this is what I use in a lot of commercial projects. This does I2C in Spin so it is not fast, but for saving variables into EE so that they auto-load on start-up, it works great. Note, too, that I always use 64K EEPROMs in my projects. If you have a 32K EEPROM you can change the page size value and save-as for the 32K type.

    If you wanted to save a long variable, you would do this:
      ee.wr_long(@myVar, myVar)
    
    Easy-peazy.
  • Clock LoopClock Loop Posts: 2,069
    edited 2020-09-13 18:27
    I also save variables to eeprom in my trillion year clock project.



    https://hackaday.io/project/162734-a-trillion-year-clock

    https://forums.parallax.com/discussion/169407/a-trillion-year-clock-addons-bigbang-current-time-and-eeprom-backup-are-included

    I use JonnyMac's objects:

    jm_24xx256.spin
    which uses his
    jm_i2c.spin

    I couldn't find his stuff in the GITobexHUB, so I don't know where it is other than in my attached zip file for my TrillionYearClock.zip attached file in the link at either of the above projects.

    It looks like he attached the 512 object, where my project uses the 256.

    You write it like this, and when your program starts, that variable's written value is loaded with the program automagically, it overwrites that exact variables data in the eeprom.
    (at least with the 256 version, I don't know what the 512 version does)
    eeram.wr_long(@variableaddress, variable)
    

    Thanks JonnyMac! I stand on the backs of giants, and you are one of them!
  • Thanks John! I was just that easy.

    Thanks again all!
  • JonnyMacJonnyMac Posts: 9,102
    edited 2020-09-13 21:06
    My pleasure, Douhg! :)
  • Clock Loop wrote: »
    I also save variables to eeprom in my trillion year clock project.

    But will the eeprom last a trillion years and not lose data in the mean time?
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2020-09-14 05:13
    rbehm wrote: »
    But will the eeprom last a trillion years and not lose data in the mean time?

    As the optimist could be heard saying as fell down past the 40th floor from the top of an 80 story building

    so far, so good!

  • rbehm wrote: »
    But will the eeprom last a trillion years and not lose data in the mean time?

    As the optimist could be heard saying as fell down past the 40th floor from the top of an 80 story building

    so far, so good!


    If you look at the actual thread, you will see that this issue was already discussed, please discuss it there. The island of stability also becomes an issue if you want to get technical.
Sign In or Register to comment.