| Details |
Message |
|
Read-Only
Author Simon TELLIER
Posted 30-Apr-2012 09:07 GMT
Toolset C51
|
 C51/LX51: Place some variables in a specific page apart
Simon TELLIER
Hello,
I am working on a project based on a C8051F353 from Silabs.
This project needs some non-volatile variables to be stored, using
internal Flash.
I manage to read, write, and erase data to flash BUT:
-a write needs an erase, and erase can't be performed on less than a
page
All data can be kept, by reading the concerned page, modify the
requested data, erasing the page, and write the modified copy.
Since I have declared my non-volatile data into the main program
as global variables with "code" prefix, this data is located into
program in Flash. When I want to write to this data, I am so erasing
and rewriting page of running program, which results in reset of
device.
I would like to be able to place non-volatile data into a specific
page appart from code, into flash. So that I won't affect program
when updating data.
I think the use of SEGMENTS would be the best for me, but I can't
manage to place a specific segment in a specific page, but just at
the end of code.
I somebody have a solution, or can give me a direction to fix this
problem.
Thank you in advance.
|
|
|
Read-Only
Author erik malund
Posted 30-Apr-2012 13:50 GMT
Toolset C51
|
 have you read the datasheet ...
erik malund
... re the scratchpad?
Erik
|
|
|
Read-Only
Author Simon TELLIER
Posted 30-Apr-2012 14:19 GMT
Toolset C51
|
 RE: have you read the datasheet ...
Simon TELLIER
Thank you for the answer,
Yes I read Device, C51, and LX51 datasheets but didn't find what I
expect to do.
The only time I find something related to scratch pad is in 11.2 Data
memory part of the 8051F353 datasheet, which deal of RAM. I can't see
how this feature is related to my wishes to store variables to
Flash.
If there is a use of this scratch pad in my case, please explain
me briefly how.
Thank you,
Simon.
|
|
|
Read-Only
Author erik malund
Posted 30-Apr-2012 14:25 GMT
Toolset C51
|
 sorry
erik malund
did not know that SILabs had chips with no scratchpad
Erik
|
|
|
Read-Only
Author erik malund
Posted 30-Apr-2012 14:31 GMT
Toolset C51
|
 what I would do ...
erik malund
... would be to make a small assembler routine that defines the
location and does erase and write (read is in C). This also avoids
the chance that the C code decides to write some variable other than
the "configurations data" to memory, which when directed to flash
would be disastrous.
In assembler you have it "by the balls" and can locate to your
hearts delight. Declare the "flash storege start" in the assembler
fil and meke it public.
Erik
|
|
|
Read-Only
Author Simon TELLIER
Posted 30-Apr-2012 14:40 GMT
Toolset C51
|
 RE: what I would do ...
Simon TELLIER
No problem.
I was thinking about a dynamic way to allocate a page, in relation
to the compiled code.
Isn't it possible with SEGMENTS? The PAGE Alignment Type would be
perfect for that (cf http://www.keil.com/support/man/docs/lx51/lx51_in_cmb_segments.htm)
but I can't find a way to set this setting by myself instead the
linker.
The LX51 documentation for Raisonance explain how to perform an
Alignment relocation, and I was expected it was possible with the
Keil version.
If there is no solution with that, I will place manually my variables
at specific adresses, out of code (but I am not able to know before
compiling the adresses used for porgram).
Am I right?
|
|
|
Read-Only
Author erik malund
Posted 30-Apr-2012 14:57 GMT
Toolset C51
|
 you do not want to do that because
erik malund
I was thinking about a dynamic way to allocate a page, in
relation to the compiled code.
you do not want to do that because that may lead to losing the config
data when upgrading the code, put it in the lsat page.
The LX51 documentation for Raisonance explain how to perform an
Alignment relocation, and I was expected it was possible with the
Keil version.
it is, but I am, for the '51 "IDE dumb" because I have done all my
'51 stuff by commandlime
Erik
|
|
|
Read-Only
Author Simon TELLIER
Posted 30-Apr-2012 15:05 GMT
Toolset C51
|
 RE: you do not want to do that because
Simon TELLIER
you do not want to do that because that may lead to losing the
config data when upgrading the code
It is not a problem for me since the device should be programmed just
one time, and we have parameters in a database. The non-volatile
parameters are modified by code via UART communication, and without
updating the code.
Placing them to the last page (I think about using absolute
location using ^0x1dFF as adress to specify the last adress of the
last page) seems to be the best idea.
How am I sure that the code won't overwrite this dataspace? Will
the linker inform me about that?
Thank you Erik.
|
|
|
Read-Only
Author erik malund
Posted 30-Apr-2012 16:09 GMT
Toolset C51
|
 famous last words
erik malund
the device should be programmed just one time
famous last words
Placing them to the last page (I think about using absolute
location using ^0x1dFF as adress to specify the last adress of the
last page) seems to be the best idea.
beware of the special bits in the last page, refer to the flash map
in the datasheet. Look up page size vs. start of config area.
How am I sure that the code won't overwrite this dataspace?
Will the linker inform me about that?
the linker has a parameter "size of CODE memory" again, I do not know
how to initialize it in the IDE. This, will keep the code out of the
last bit of memory.
Erik
|
|
|
Read-Only
Author Simon TELLIER
Posted 1-May-2012 07:47 GMT
Toolset C51
|
 RE: famous last words
Simon TELLIER
beware of the special bits in the last page
You're right. I noticed few time after my post that my flash was
write protected. The last byte of the last page is a security byte
and any erase request on this page generates a reset. So I mustn't
use the last page for my non volatile variables.
I'm going to look for the size of code parameters.
Thnak you.
|
|