DavidM
11-25-2010, 03:39 AM
HI,
I have code for saving VARIABLE's back in the eeprom, this works perfectly and I have been using this routine for ages.
In My "VAR" Block, I so far have defined all of my variables as LONG's
A section of these variables are saved, so at the start of the variables that need to be saved I have a variable called VarMemStart
Then I have all my Long variables defined
and then at the end of these, I have another Variable called "VarMemEnd"
example
VAR ' My variable Block
LONG MyVariable1, MyVariable2
LONG VarMemStart
LONG MySaveableVariable1, MySaveableVariable2
LONG VarMemEnd
When I need to save these variables, I call my save routine like so..
EepromSave (@VarMemStart, @VarMemEnd)
I need to define the start and end variables as LONGS as these are Address pointers used in my save routine.
What I understand is that when SPIN get compiled, it will RE-ORDER all the variables in the following order..
LONGS, WORDS then BYTEs ( and I think DAT's as well after that)
Q1) How do I save the BYTES? ( This is my main question )
I need to have some STRINGS saved as well as my other longs, But If I declare a BYTE like..
LONG VarMemStartBytes
BYTE MySavableByteVariable[17] ' This will be a 16 BYTE STRING , with one extra byte for the termination.
LONG VarMemEndBytes
When this gets compiled , my LONG variable Pointers will get "Grouped" together with the other LONGS, So I wont be able to point to the start and end of my variables.
And Before you ask, Why don't I just save ALL VARIABLES?
I have half the eeprom/ram taken up with big arrays of LONGS which stores data ONLY While the device is ON, So I don't need to save all of these, AND, If I were to save them, it would add considerable time , that the USER would notice.
My Main reason for saving SMALLER sets of variables, is to SAVE SYSTEM PARAMETERS (User Preferences) which is invoked every time the user changes one of these settings.
If i were to create MULTIPLE VAR BLOCKS , would the COMPILER keep these separate? , but even if this happened, then I still have the issue of the LONG ADDRESS Pointers being grouped together!
Q2) Is it possible to save a STRING as a series of LONGS, where 1 Long can be used for 4 BYTES?, That way it would not be mixed up, i.e consecutive.
Q3) Would the use of a DAT Block be a better option? Can I save just a DAT Block?
Any Ideas?
Thanks
Dave M
I have code for saving VARIABLE's back in the eeprom, this works perfectly and I have been using this routine for ages.
In My "VAR" Block, I so far have defined all of my variables as LONG's
A section of these variables are saved, so at the start of the variables that need to be saved I have a variable called VarMemStart
Then I have all my Long variables defined
and then at the end of these, I have another Variable called "VarMemEnd"
example
VAR ' My variable Block
LONG MyVariable1, MyVariable2
LONG VarMemStart
LONG MySaveableVariable1, MySaveableVariable2
LONG VarMemEnd
When I need to save these variables, I call my save routine like so..
EepromSave (@VarMemStart, @VarMemEnd)
I need to define the start and end variables as LONGS as these are Address pointers used in my save routine.
What I understand is that when SPIN get compiled, it will RE-ORDER all the variables in the following order..
LONGS, WORDS then BYTEs ( and I think DAT's as well after that)
Q1) How do I save the BYTES? ( This is my main question )
I need to have some STRINGS saved as well as my other longs, But If I declare a BYTE like..
LONG VarMemStartBytes
BYTE MySavableByteVariable[17] ' This will be a 16 BYTE STRING , with one extra byte for the termination.
LONG VarMemEndBytes
When this gets compiled , my LONG variable Pointers will get "Grouped" together with the other LONGS, So I wont be able to point to the start and end of my variables.
And Before you ask, Why don't I just save ALL VARIABLES?
I have half the eeprom/ram taken up with big arrays of LONGS which stores data ONLY While the device is ON, So I don't need to save all of these, AND, If I were to save them, it would add considerable time , that the USER would notice.
My Main reason for saving SMALLER sets of variables, is to SAVE SYSTEM PARAMETERS (User Preferences) which is invoked every time the user changes one of these settings.
If i were to create MULTIPLE VAR BLOCKS , would the COMPILER keep these separate? , but even if this happened, then I still have the issue of the LONG ADDRESS Pointers being grouped together!
Q2) Is it possible to save a STRING as a series of LONGS, where 1 Long can be used for 4 BYTES?, That way it would not be mixed up, i.e consecutive.
Q3) Would the use of a DAT Block be a better option? Can I save just a DAT Block?
Any Ideas?
Thanks
Dave M