Shop OBEX P1 Docs P2 Docs Learn Events
Where in the stack — Parallax Forums

Where in the stack

Sabre00Sabre00 Posts: 30
edited 2010-01-18 12:22 in Propeller 1
This question has no doubt been asked before but I was searching in vain over the weekend.

My problem is, is that I would like to save one byte of data in the propellers EEPROM. I Would like for this value to be loaded into the program after boot up.

I have had experience in the past with EEPROMS and I have since then upgraded to SD cards. However, since I made the SD card removable I would not like to place the byte on the SD card for a user to remove the by accident. Also, it would be a big waste to place a 256Kb EEPROM in the system for only one byte of storage space.

I know conventionally stacks work from the bottom up, but I would just like some clarity on how to write to the EEPROM as to not affect the runnings of the program that has a couple Cog initialization commands.

Or if I have to bite the bullet and place the EEPROM in the system or there is another way to tackle this problem.

Any help - even pointing me to the correct thread, would be greatly appreciated.

Sabre00

Comments

  • MagIO2MagIO2 Posts: 2,243
    edited 2010-01-18 12:22
    You don't have a 256kb EEPROM? How does that work? Bet you lie! ;o)

    But to answer your question:
    You simply write the value to the same address in EEPROM that the variable has in HUB-RAM. Then you even don't need code to read it back when you start the next time. It's already pre-initialized.

    In general:
    If you want to put data into the first 32kB of EEPROM you should go top-down with that data. And you can put data there until you reached the start of stack. The stack itself does not care whether there was data already. Stack operations always come in pairs, one push means that there has to be one pop. This means that each pop will find a valid value - if not overwritten by code running nuts - because it has been written before.
Sign In or Register to comment.