Shop OBEX P1 Docs P2 Docs Learn Events
help on lightweight memory storage object — Parallax Forums

help on lightweight memory storage object

Hi

I want to store some settings after a power sickle and found the Memory Storage Management Lightweight from Brandon Nimon in the obex. I have a 24LC256 eeprom in my project so their is place for this.
I can't figure out how to use the exel sheet with it to calculate te settings for a 24LC256 eeprom.
Can somebody help to fill in the green fields in this exel sheet and ore explain it a bit.

Thanks in advance

Stefan

Comments

  • RaymanRayman Posts: 13,805
    edited 2018-07-05 11:07
    Not what you asked for, but maybe this "Propeller EEPROM" is easier to use?
    It's what I'm using...

    Maybe you can find the "Propeller Eeprom Docs.spin" help file that goes with it...
  • I'll chime in with Ray. I save a lot of values to EEPROM, hence wrote my own EEPROM object which simplifies storing and retrieving values. Let's say, for example, that I have a global long called rebootCycles that I want to increment and store after each reboot. I can do it like this:
      ee.wr_long(@rebootCycles, ++rebootCycles)
    
    IMO, that's pretty lightweight. If you need to store in the upper EEPROM then you cannot used variable names, but it's very easy to use named constants for the upper EEPROM addresses -- like this:
      rebootCycles := ee.rd_long(RST_CYCLES) #> 0
      ee.wr_long(RST_CYCLES, ++rebootCycles)
    
    Keep in mind that a new EEPROM has all bits set so any value read from it will have all bits set; in a long this would return -1.

    My EE object and the child I2C object (which requires pull-ups on SCL and SDA) are attached. I used this object in a commercial laser-tag controller and a commercial arrow board (those big signs you see near road work to direct traffic). It's simple and I've never had any problems.
  • Hi Jon

    Thanks for the advice. I will try to use your object.

    Just a little question because i don't have much knowledge on eeproms.
    I need to stay in the upper eeprom adress range (above the 32K) because it need to survive a reprogram download. So i need to use named constants. I can manage that. But for a 24LC256 Wat is the min and max address to set that up.

    And second question. This is my only eeprom on the project. (it is also the boot eeprom.) it has only one pull up 10K. I read on your comment that it needs two. Do i need to add one and does that not interfere with the boot then?

    Thanks in advance.

    stefan
  • A 24LC256 EEPROM only stores 32k bytes: 256/8=32. You need a 24LC512 to have an upper 32k to play with.
  • Thanks for the info. Like i already told I 'm not so familiar with eeproms.

    I can swap easily to a 24Lc512. But then back again what is the adress range for upper 32K?
  • Here is a pointer to the thread that ensued when I asked the same question. Plenty of good advice.
  • stef wrote: »
    Thanks for the info. Like i already told I 'm not so familiar with eeproms.

    I can swap easily to a 24Lc512. But then back again what is the adress range for upper 32K?

    It's 32768 Decimal (8000 Hex) to 65535 Decimal (FFFF Hex). You can use the Calculator in Windows in Programmer mode to switch between Decimal and Hex.
  • Thanks to all. I'll give it a try.


  • JonnyMacJonnyMac Posts: 8,912
    edited 2018-07-06 16:43
    stef wrote: »
    Hi Jon

    Thanks for the advice. I will try to use your object.

    Just a little question because i don't have much knowledge on eeproms.
    I need to stay in the upper eeprom adress range (above the 32K) because it need to survive a reprogram download. So i need to use named constants. I can manage that. But for a 24LC256 Wat is the min and max address to set that up.

    And second question. This is my only eeprom on the project. (it is also the boot eeprom.) it has only one pull up 10K. I read on your comment that it needs two. Do i need to add one and does that not interfere with the boot then?

    Thanks in advance.

    stefan

    As has been pointed out, if you use a 32K EEPROM in your design you will not have any protected when you do a new download to EEPROM. Every one of my designs uses 64K; the cost differential is small, and the benefit very big. In the laser-tag system, for example, it is actually three applications that can be loaded from the SD card into the Propeller EEPROM (another reason for this object). The Editor application builds the database in the upper 32K where the Referee and Player applications can access it.

    Now... if you have a design that uses a 32K memory you can use the area of EEPROM that is not used by the code or variable space -- with caution. As you make calls, this free area (the stack) is used as temporary storage. What I have done a few times is used very high memory in that space, say above $7000 (but this will depend on your app). If you write to this area it will auto-load on the next boot-up.

    Technically, the Propeller violates the I2C spec by driving the SCL line high and low. This is almost never a problem. Still, the spec says one should only pull those lines low and allow the pull-up to take the lines high when released. This allows for something called "clock stretching" where a device will hold the clock line low to indicate that it's busy. Some older Parallax boards only have the pull-up on the SDA. A friend was using the Propeller Mini in a movie prop and needed EEPROM access so I modified my I2C driver for that special case. Again, if you can do it, add the pull-up to the SCL line on your board. The pull-up will not interfere with the boot process and will allow you to run my standard driver.

    BTW, Mike Green has a really great I2C object that does drive the SCL line. You should experiment with it, too.
Sign In or Register to comment.