C51/LX51: Place some variables in a specific page apart

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.

Parents
  • ... 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

Reply
  • ... 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

Children
More questions in this forum