Shop OBEX P1 Docs P2 Docs Learn Events
non volatiles? — Parallax Forums

non volatiles?

Jimmy W.Jimmy W. Posts: 112
edited 2007-12-26 16:33 in Propeller 1
Is there anyway to make a variable persist through a power reset?
I am going to be using 1-wire temp sensors coupled with 1 wire 8 output switches to control temperatures and after I go through on my LCD and associated them with each other I would like to not have to do it again if the power goes out, I guess hard-coding them is possible but I am trying to design something that can easily be changed by some dumb installer if a sensor goes bad.


Jimmy
«1

Comments

  • Nick MuellerNick Mueller Posts: 815
    edited 2007-12-25 10:13
    Has been answered many times: Write it to the EEPROM.

    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • Jimmy W.Jimmy W. Posts: 112
    edited 2007-12-25 10:18
    I may have missed it but I have not seen a tutorial on that yet, care to illuminate or point me towards a source so·I can rtm?


    EDIT:



    As I am still waiting for my Prop to arrive is it possible to write this data towards the end of the eeprom to prevent it from being erased or does the prop write a complete image to the entire eeprom. If so, is it possible to the trim the end of the compiled file to prevent overwriting all of the eeprom as with the h8616 series chips?

    Post Edited (Jimmy W.) : 12/25/2007 10:32:42 AM GMT
  • hippyhippy Posts: 1,981
    edited 2007-12-25 10:55
    If you need to keep data across program downloads as well as across power resets, only the first 32KB of Eeprom is erased, so keep the data in Eeprom above 32KB. The ProtoBoard comes fitted with 64KB Eeprom, other boards just have 32KB.
  • Nick MuellerNick Mueller Posts: 815
    edited 2007-12-25 10:58
    > it possible to write this data towards the end of the eeprom to prevent it from being erased or does the prop write a
    > complete image to the entire eeprom.

    AFAIK, it is overwritten when you download a new programm.
    The easiest way is to have a bigger EEPROM.
    With lots of fiddling in the EEPROM, you should be able to find the addresses of your variables and make them non-volatile (until you load a new software-version and have to find the new loacation).

    Here: <http://forums.parallax.com/forums/default.aspx?f=25&m=237019&gt;
    Or search for "EEPROM"

    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • deSilvadeSilva Posts: 2,967
    edited 2007-12-25 11:06
    Not sooo much fiddling smile.gif
    OBJ
     Eeprom : "Eeprom"
    
    PUB x
       Eeprom.VarBackup(firstAddress, lastAddress)
       Eeprom.VarRestore(firstAddress, lastAddress)
    
  • Nick MuellerNick Mueller Posts: 815
    edited 2007-12-25 11:39
    > Not sooo much fiddling smile.gif

    Oh, great.

    My answer again was too short to be helpful. smile.gif
    What I meant is the following construct:

    CON
      someConstant = 1234
    
    VAR
      long volatileValue
    
    PUB
      volatileValue:= someConstant
    
    



    Now if you find the address in EEPROM of "someConstant"*) and overwrite it with a new value you do have something configurabe with (maybe) usefull default-values.
    Not verified wether that works!

    *)
    And for sure not a var. You'll never find that in EEPROM!

    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO

    Post Edited (Nick Mueller) : 12/25/2007 11:44:04 AM GMT
  • deSilvadeSilva Posts: 2,967
    edited 2007-12-25 12:42
    eeprom.varBackup/Restore is a tool... You have to apply it intelligently smile.gif
    DAT
      somePseudoConstant LONG 1234
    
    PUB calibrate(newValue)
      somePseudoConstant := newValue
      eeprom.varBackup(@somePseudoConstant, @somePseudoConstant+3)
    



    However.. I just read through eeprom version 0.6 ... I do not like the that FromRAM writes a complete page (upto 64 bytes). But maybe this has already been fixed in the meantime. Otherwise fix line 49 yourself..
  • Jimmy W.Jimmy W. Posts: 112
    edited 2007-12-25 16:04
    Hey, just a last few questions:

    will eeprom.varRestore cause a problem if it hasnt stored a var yet? 1st upload?

    if·I needed to store several variables through power loss would it be better to just implement 1 function to restore them all or to serialize all of the arrays into 1 big heap then reloading them and de serializing?



    EDIT: too early to spell correctly I guess [noparse]:)[/noparse]
  • deSilvadeSilva Posts: 2,967
    edited 2007-12-25 16:27
    Jimmy W. said...
    will eeprom.varRestore cause a problem if it hasnt stored a var yet? 1st upload?
    Please think again after 9 o'clock smile.gif
    said...
    if I needed to store several variables through power loss would it be better to just implement 1 function to restore them all or to serialize all of the arrays into 1 big heap then reloading them and de serializing?
    This is a more intelligent question smile.gif In fact we did not tell you that each writing to an EEPROM involves a small risk when power breaks. Internal pages (=64 bytes) can get corrupted, or data spanning some pages can get inconsistent.

    Reducing the number of updates will reduces the probability of failures.

    A professional program would put all parameters together in some compact block, add a CRC, write this block alternately onto two different places, check the CRC when loading, and re-load again from the alternative place in case of defects..
  • Mike HuseltonMike Huselton Posts: 746
    edited 2007-12-25 16:37
    May I humbly suggest Ramtron. It can write at nanosecond speeds and retains data better than EEPROMS.
    Offerings are Serial Two Wire, Serial SPI, and Parallel High Speed.

    The prices are amazing - I don't know why we don't ditch EEPROMS altogether.

    Just my two cents...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    JMH
  • deSilvadeSilva Posts: 2,967
    edited 2007-12-25 16:49
    I read their datasheets same days ago: 3.3V 32 MB chips seem to be mostly compatible.
    What are their prices... For a 24C256 I pay 1€ (+VAT) in Europe.

    It seems they are stil the only providers for FRAM!? This is generally bad... It means:
    - no safety line
    - over-prized
    - possibly technology flop
  • Mike HuseltonMike Huselton Posts: 746
    edited 2007-12-25 17:06
    See: http://www.fujitsu.com/emea/services/microelectronics/fram/

    I'll get more references. The Ramtron Mouser page is http://www.mouser.com/catalog/632/220.pdf

    I'm excited because these are drop-in replacements for high-speed static RAMs. And no tricky timing.

    Again, food for thought...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    JMH
  • bambinobambino Posts: 789
    edited 2007-12-25 19:02
    Quantum, Have you tried one out yet!
  • Mike HuseltonMike Huselton Posts: 746
    edited 2007-12-25 21:19
    Frankly, I had forgotten in the whirl of things. I will order 2 each of the Serial, SPI and Parallel units - according to my bank account.

    I'll give the forum a full report.

    Well, now I'm committed...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    JMH
  • deSilvadeSilva Posts: 2,967
    edited 2007-12-25 21:47
    $21, please smile.gif ..plus shipping
  • Mike HuseltonMike Huselton Posts: 746
    edited 2007-12-25 21:51
    By the way, what do you recommend for a 3.3V TO92 100 MA low dropout regulator. I am ordering from Mouser.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    JMH
  • Mike HuseltonMike Huselton Posts: 746
    edited 2007-12-25 21:56
    What megabytes of ram are you speaking of, sir?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    JMH
  • deSilvadeSilva Posts: 2,967
    edited 2007-12-25 22:04
    32kByte, as in a 24C256 smile.gif
    There are some differences in the I2C protocol with the lower capacity types, but it seems that from 24C128 on it will be compatible. To check it as a replacement for the Propeller EEPROM it must be AT LEAST 24C256.

    But I just see, they do not seem to have a 3.3V type of that capacity.
    The parallel chip is the most expensive, though....
  • Mike HuseltonMike Huselton Posts: 746
    edited 2007-12-25 22:19
    That turns out not to be the case:

    877-FM18L08-70-PG FM18L08-70-PG PDIP-28 256K 32K x 8 70ns -40 to +85 3.0v - 3.6v $9.97

    The serial parts have similar specs, but slower access, being serial in nature.

    I want to order two sets, as I have had multiple strokes this year and my fine motor control sucks.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    JMH
  • Erik FriesenErik Friesen Posts: 1,071
    edited 2007-12-25 22:28
    I do a routine writing to a 4k fram that uses a separate cog that has acess to the variable that I want to keep updated. It automatically writes every two seconds or so but only on the condition that a pin( hooked up to the precap power supply with a diode) is high. So far I have had no miswrites on writes spanning 16 bytes.
  • bambinobambino Posts: 789
    edited 2007-12-26 00:07
    I got an e-mail letter from them a year ago wanting to know if I wanted to sample on of ther fram's. I wrote back and said that I would(Thinking along the same lines, that it could replace the eeprom).
    I forgot all about it(They had too), until 2 weeks ago when they called and left a message on my answering machine asking me if I still wanted them.
  • deSilvadeSilva Posts: 2,967
    edited 2007-12-26 01:54
    @bambino: Please keep us informed about messages on your answering machine smile.gif
    @Quantum:
    - 3.3V: I was referring to the I2C version
    - Speed: I2C is limited to 1MHz, I think this is a matter of protocol; SPI should not be handicapped so much
  • bambinobambino Posts: 789
    edited 2007-12-26 04:10
    @desilva: 10-4 buddy, be glad to do that!
    @Quantum: Good luck and keep us posted. If it works for prop eeprom replacement, I'll be placeing an order next
  • Mike HuseltonMike Huselton Posts: 746
    edited 2007-12-26 04:31
    I stand corrected - the i2C version is indeed only available in the 5V model. The SPI and parallel versions run @ 3.3V.

    frankly my interest was in the SPI and Parallel versions anyway, but that doesn't allow me to weasel out of my blanket statement.

    I truly apologize and let my time spent in the Iron Maiden be a lesson to me. wink.gifwink.gifwink.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    JMH
  • Jimmy W.Jimmy W. Posts: 112
    edited 2007-12-26 04:33
    @deSilva If you want to test this for us as well and report how everything goes, I would LOVE to use this as a replacement for the itty bitty 32kb eeprom we are using now + the dangers involved I would more than gladly send you some direct. I am quite scared of corrupting the eeprom as I will probably have to write to nonvolatile data ~·6 per hour or more depending on user interaction.

    Jimmy
  • deSilvadeSilva Posts: 2,967
    edited 2007-12-26 04:56
    Jimmy,
    I think I will not do that smile.gif
    When there is a direct replacement available (a 3.3V 24256) I shall certainly try this, but not "test" it.

    You need not be afraid that you harm the EEPROM. Maybe I have been a little bit unclear about that. It is just that SOMETIMES data cannot be safely written to it, in case of power problems. The probability for such issues is low, and can most like be further decreased by adding a good (ceramic) cap close to the EEPROMs supply pins (220nF or up, not quite cheap...).

    Writing once per 10 minutes is not much. I should not care too much, but double buffering your date - as I described - will further stabilize your system.
  • deSilvadeSilva Posts: 2,967
    edited 2007-12-26 10:02
    There has been the request for the Eeprom routines mentioned here... Indeed I do not remember where I got them from... They are labeled "Parallax, september 2007"...
    I post them here....
  • Erik FriesenErik Friesen Posts: 1,071
    edited 2007-12-26 14:26
    Desilva, How do you verify which buffer is correct in the case of a miswrite in a constantly changing variable?
  • deSilvadeSilva Posts: 2,967
    edited 2007-12-26 15:26
    Just as I said: Use a checksum (or a CRC).
    This is why you should keep all data to be updated together, example (just hacked in, most likely two typos and one logic error in it smile.gif
    { eepromSaver v.0.2 unchecked by deSilva Dec 2007}
    DAT
    updateBlock LONG   'exempli gratia
     p1  byte "a string",0
     p2  LONG $FFFF_FFFF[noparse][[/noparse] 3]
     p3  WORD 123
     storedChecksum LONG 0
    
    altUpdateBlock LONG
    BYTE 0[noparse][[/noparse] @storedChecksum-@updateBlock+4]
    
    
    PUB main | checksum, updateBlockLength
       updateBlockLength := @storedChecksum-@updateBlock+4
       checksum := computeChecksum(@updateBlock, updateBlockLength-4)
       IF checksum <> storedChecksum   ' Houston, we have a problem....
          BYTEMOVE(@updateBlock, @altUpdateBlock, updateBlockLength) 
          checksum := computeChecksum(@updateBlock, updateBlockLength-4)  
          IF checksum <> storedChecksum   ' Now it's your turn: a phone call is requested
    
          storeTheBlock
    
     ' call storeTheBlock whenever you need an a backup
            
    
    PUB storeTheBlock | updateBlockLength
         updateBlockLength := @storedChecksum-@updateBlock+4 
         storedChecksum := computeChecksum(@updateBlock, updateBlockLength-4)
         REPEAT 
            EEPROM.backup(@updateBlock, @updateBlock+updateBlockLength)
            EEPROM.retrieve(@altUpdateBlock, @altUpdateBlock+updateBlockLength)
         UNTIL storedChecksum == computeChecksum(@altUpdateBlock, updateBlockLength-4)
         EEPROM.backup(@altUpdateBlock, @altUpdateBlock+updateBlockLength)
    
    PUB  computeChecksum(addr, size): sum | endAddr
         endAddr := addr+size-1
         REPEAT WHILE  addr=> endAddr
            sum := sum<<1 + BYTE[noparse][[/noparse] addr++] +1
    
    

    Post Edited (deSilva) : 12/26/2007 5:36:12 PM GMT
  • Fred HawkinsFred Hawkins Posts: 997
    edited 2007-12-26 16:33
    deSilva said...
    There has been the request for the Eeprom routines mentioned here... Indeed I do not remember where I got them from... They are labeled "Parallax, september 2007"...
    I post them here....
    I think you have the 8th Ed Kit Lab from http://forums.parallax.com/showthread.php?p=678271·(plus some extras, chiefly tests)

    Post Edited (Fred Hawkins) : 12/26/2007 4:40:35 PM GMT
Sign In or Register to comment.