Shop OBEX P1 Docs P2 Docs Learn Events
Saving data in an application — Parallax Forums

Saving data in an application

tbriggstbriggs Posts: 9
edited 2007-02-08 15:50 in Propeller 1
I would like to save some values for later use by the propeller. I am reading a count and would like to save that information so that the next time when I turn the unit on it can read that previous count. Please excuse me if I am not asking the question correctly.

Thanks in advance!

Comments

  • hinvhinv Posts: 1,253
    edited 2007-02-07 16:20
    Since the prop usually has an I2C 32k eeprom connected for booting, this shouldn't be too tough. If it is Spin code that you are writing it in, you could use the DAT directive to load in data into the prop. If you store your program to eeprom, after you power up, it will load the data from eeprom. Your program could just overwrite the data byte in the eeprom via I2C. Be careful, however, because this self is close to self modifying code, and one mistake can be a real pain to debug.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-02-07 16:27
    You can save information in the end of the EEPROM (much the same as with the Stamps) since programs are loaded beginning at location zero. When you download a new program, the first 32K of the EEPROM is cleared, so you'll lose any stored data if the EEPROM is only 32K. There are two different I2C drivers in the Propeller Object Exchange. Either will work for this.
  • glentechglentech Posts: 35
    edited 2007-02-07 17:40
    I have been using the 512byte fram chip ( its accross the page from the microchip eeproms in the mouser catalog). I have it connected to the OS eeprom pins and have the address pins set different than the os eeprom. I set a cog running that checks A given address and loads the fram every second.(using the ctra)On startup my main program loads the address with the fram value. I am using the i2cobject from the object exchange with a few mods to directly load long values. You need to be careful that you don't load values to the eeprom in a loop or you may burn it out. 1,000,000 cycles they say I don't know.
  • QuattroRS4QuattroRS4 Posts: 916
    edited 2007-02-07 21:04
    Mike Green has given examples in previous posts - I used similar to write/read to/from a second eeprom - using the same code except editing the pin no.'s for SDA,SCL - mike has a minimal_i2c_driver example out there. My 2nd eeprom is used to store settings - which are rarely changed - so the finite amount of write cycles is not an issue. If your write requirements are very frequent - why not consider the SD card option by Rokicki

    Have a look at the following for some pointers:
    this discusses extra storage - eeprom or SD card..

    http://forums.parallax.com/forums/default.aspx?f=25&m=167601

    the following is specifically for I2C / EEProm the example given here is for the boot eeprom but if you wanted to add an additional eeprom to other pins - just edit pin no.'s .

    http://forums.parallax.com/forums/default.aspx?f=25&m=166651

    Or otherwise 'bussed' devices on same lines with different addresses -
    note - Its a philips protocol - worth reading - especially master/slave - some legalities there..

    and if you go the SD card route:
    http://forums.parallax.com/forums/default.aspx?f=25&m=162235

    either way when it comes to I2C - Mike Green is the man or SD card its Rokicki !!

    Thats my humble opinion at least...
  • tbriggstbriggs Posts: 9
    edited 2007-02-08 04:27
    When writing to eeprom how do you know where it is putting it and how do you know where to retrieve it?
    Can someone post a snippet of code?

    Thanks!
  • Mike GreenMike Green Posts: 23,101
    edited 2007-02-08 04:51
    There is a snippet of code in the comments of the Simple_I2C_Driver in the Propeller Object Exchange.
    There are similar examples in the I2C Library in the Object Exchange. If you have any questions after
    you've looked at them, ask here specifically. Pretty much all of the objects in the Object Exchange have
    Demo Programs as part of their archive that illustrate their use. They often include circuit diagrams for
    the connection of the related parts.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-02-08 06:52
    The key to what you want to do is to allocate a space for the data you want to keep, and keep track of the absolute address of the data space. There are a few ways to do this, but you should follow Mike's advice first and understand how to access the data.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • tbriggstbriggs Posts: 9
    edited 2007-02-08 15:50
    Thanks very much for your help. I have looked at some of the examples and have successfully wrote to and read from. This is a big deal for me!! I still need to work on the theory part......

    Thanks!
Sign In or Register to comment.