Seeding a variable
pogertt
Posts: 33
I wrote the following program to seed a pair of variables.
My intent is to have the two variables set to values saved in EEPROM.
The first time the program runs, it retrieves a zero from Normal's addy.
It then causes a value to be written to Normal's addy, so on future runs of the program, the variable will be retrieved rather than a zero.
My application manipulates the variable, and will save and restore that value correctly.
If I use Hex Editor Neo to modify a Propeller Tool generated Eeprom file by inserting my seed values of 300 and 3600 into locations $7000 and $7010 the
Propeller Tool finds a checksum error and won't load the file.
My question is:
Is the sequence as written the only way to get variables into eeprom so they will be read on the first run of the program?
My intent is to have the two variables set to values saved in EEPROM.
The first time the program runs, it retrieves a zero from Normal's addy.
It then causes a value to be written to Normal's addy, so on future runs of the program, the variable will be retrieved rather than a zero.
My application manipulates the variable, and will save and restore that value correctly.
If I use Hex Editor Neo to modify a Propeller Tool generated Eeprom file by inserting my seed values of 300 and 3600 into locations $7000 and $7010 the
Propeller Tool finds a checksum error and won't load the file.
My question is:
Is the sequence as written the only way to get variables into eeprom so they will be read on the first run of the program?
Comments
-Phil
Note that variables (VAR) are initialized to zero.
I can get my program to change and save variables, and reload them correctly on subsequent power down, power up cycles.
I was looking for an alternate way to place a value in an eeprom location that would be read once, on the first time the program is loaded from eeprom into propeller ram, and then read the value that the operator may or may not have changed during program execution.
It looks like the read address, compare to zero, then write a default value is the eaziest to impliment.
I am curious how the checksum is generated, and if there is a way to manipulate it after modifing the assembled code.
-Phil
If I then edit the eeprom file by adding extraneous data and manipulate the value in $0005, the propeller tool will load the modified file, but it won't display or load my added data.
I tried adding my extra data in both the Yellow variable block, and in the Blue stack/free space areas.
Adding extra data to the area just above the beginning of the stack area won't help because that will get used by your program for calls and local variables. Placing your data into a variable block will work as long as you know where you're putting it and what variable resides there. If I were going to store some initial data in an .eeprom file, I'd probably put it right at the end of the 32K block of memory. That area is usually unused and is easily accessed using BYTE / WORD / LONG. Some I/O objects, like the Graphics object, use this area, but most do not.
Phil is right though. The easiest area to use for this sort of thing is a DAT block.
You're making this way too hard. This is all you need to do in your program:
instead of declaring Normal and Delayed as VAR variables.
-Phil