|
|
View previous topic :: View next topic |
Author |
Message |
billy Guest
|
Reading and writing to flash |
Posted: Mon Jul 09, 2007 1:30 pm |
|
|
The help files on reading and writing to flash are as clear as mud so can anyone help explain a few things.
When the helpfile says that the function write_program_memory( address, dataptr, count ); needs a pointer to a byte what it actually means is that it needs to be passed a variable and that the count value needs to relate to the size of the variable. Am I right?
That would explain some of the examples provided where dataptr is clearly not a pointer, it is a variable, and clearly not an int8, byte or char.
So, assuming I'm right about this, does this mean that if I do the following:
Code: |
signed int16 SomeVariables[32];
write_programe_memory( 0x1000, SomeVariables, 64);
|
it will copy all 32 Sint16 values from the array to flash?
And will this copy the values back?
Code: |
signed int16 SomeVariables[32];
read_programe_memory( 0x1000, SomeVariables, 64);
|
-------------
My next question is does this work with arrays of pointers, can I do this:
Code: |
signed int16* SomePointers[32];
read_programe_memory( 0x1000, SomePointers, 64);
|
because I need to save large arrays of variables and pointers to variables so they are preserved during power failure.
(I can't test this all out because I'm working from home this week and I don't have my Pics or programmer here)
Hope someone can help! |
|
|
grasspuddle
Joined: 15 Jun 2006 Posts: 66
|
|
Posted: Mon Jul 09, 2007 1:44 pm |
|
|
program memory is the executed code, I believe you want the 'write_eeprom()' and 'read_eeprom()' command
see example ex_intee.c |
|
|
billy Guest
|
Reading and writing to flash |
Posted: Tue Jul 10, 2007 3:11 am |
|
|
Yes, the executed code is stored in flash! On many devices, including the one I'm using (18f4680) the flash is readable and writable by the user code. In my case I have 64kB of flash and my code (almost fully written) uses 16%. this means I can reasonably use 50% (32kB) to store data. Using the EEPROM is not an option as it only has 1024 bytes and I need to store more than 8k of data.
What I wanted was some clarification on how the write_programe_memory(...) functions worked when using different data types like int8, Sint16 and arrays of these variables and arrays of pointers.
About half of the data I want to save to flash are actually pointers so I want to make sure I am saving and retrieving the pointer, not the variable it points to.
Compiler version is 4.041 |
|
|
Billy Guest
|
|
Posted: Wed Jul 18, 2007 7:27 am |
|
|
Ok, I worked it all out and posted some example code showing how to read and write various types of data and pointers to flash - this is now in the code library section of the forum |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|