Shop OBEX P1 Docs P2 Docs Learn Events
Variable on Eeprom — Parallax Forums

Variable on Eeprom

Hello,
I need your help for my new project. Please excuse my bad English,I use Google translator.
So far, I have successfully programmed Atmel AVR. The Atmel chip has an Eeprom I once with
Variables then describe (TxT file) the then stay saved. When starting the program
they are then read and then serve to Course of the program.
Now it wants to do it with the propeller and spin.
But a propeller has no Eeprom but only the Memory chip.
Here is my problem: How do I do that with the Propeller.

Gruss Ulrich

Comments

  • The Propeller loads its software into internal RAM from an external I2C EEPROM chip so you can always talk to the EEPROM over I2C. If your Spin program has variables then it is a simple matter of writing to EEPROM using the "address of the variable in RAM" since the variable is part of the binary image loaded from EEPROM on reset. This means that variables will be automatically "preset" on power-up etc with the last information that was written to EEPROM rather than zeros or blanks.

    When a new program is loaded into EEPROM the loader automatically erases the first 32kB but most EEPROMs are 64kB so you can safely store text and files in the upper half that are not erased when a new program is loaded.

    With a little bit more information about your application and what language you are using we should be able to make that answer a little clearer :)

    Cheers!
  • Hi Peter,
    Thank you for the fast answer.
    The application is a telescope control. The two directions,
    vertical and horizontal, I've ever programmed in an extra cog (with spin).
    And as you described it with the Eeprom, I also imagined it.
    Attached is a configuration file that is loaded into the Eeprom when needed and
    Always stays in it. From left to right, the first 6 digits are the name of each line
    Variable and last 4 digits the contents of the variable. These variables must be in the
    Starting the controller are loaded, they are telescope-dependent.
    I hope this helps you further,

    Thank you, Ulrich
  • msrobotsmsrobots Posts: 3,704
    edited 2018-02-08 19:03
    Hallo Ulrich,

    willkommen im Propeller Forum!

    wie Peter schon geschrieben hat, ist es ganz einfach Konfigurations-Parameter zurueckzuschreiben.

    Beim Start laed der Propeller die ersten 32K vom EEPROM ins RAM. Das praktische daran ist das die adressen dieselben bleiben.

    Also wenn das SPIN program eine globale variable in der DAT section hat, wird diese beim START aus dem EEPROM geladen. Wenn du nun einen neuen wert dort speichen moechtest, der beim naechsten start verfuegbar sein soll, musst du nur im EEPROM genau diesen wert ueberschreiben.

    Die EEPROM adresse ist dieselbe wie die RAM adresse.

    In der OBEX findest du unter anderem folgendes EEPROM modul Generic I2C EEPROM Driver


    Ein Beispiel:
    OBJ
    eeprom: "I2C_ROMEngine.spin"
    ...
    DAT
    RaFein long 5
    RaGene long 239
    ...
    
    PUB saveSetting(newFein,newGene)
       eeprom.writeLong(@RaFein,newFein)
       eeprom.writeLong(@RaGene,newGene)
    ...
    

    @RaFein gibt in SPIN die Adresse der Variable RaFein im HUB-RAM, und diese Adresse muss dann im EEPROM ueberchrieben werden.

    viel spass mit dem propeller...

    Mike
Sign In or Register to comment.