cancel
Showing results for 
Search instead for 
Did you mean: 

const[] @ Fixed address.

dan10
Associate II
Posted on September 08, 2009 at 07:39

const[] @ Fixed address.

6 REPLIES 6
dan10
Associate II
Posted on May 17, 2011 at 13:22

I have been able to used FLASH_ProgramHalfWord, to write data into a const [] (only as long as it is initialised to all 0xFFs first.)

(FLASH_ProgramHalfWord((UINT32)&ARRAY[1],0xAA);) //writes AA into ARRAY[1],

however my array size is large, (2048 bytes) this was located in ram, but to free memory usage we are moving it into flash. Because the array is so big it is not really convieniant to initialise all the data to 0xFFs, is there a way I can force ARRAY[] to be located at a fixed address? For example, 0x800E800, then I can erase my array (initialise it to 0xFFs) by Erasing the pages from 0x800E800, and 0x800EC00).

Is this possible?

Regards

Dan

paulsmitton9
Associate III
Posted on May 17, 2011 at 13:22

Yes, but it depends on your compiler, so you would need to post that information here.

If you are using GNU, then you need to reserve a section in your memory layout file (using KEEP and align), and then force your array into it using:

const vu8 __attribute__((section(''.myflashsection''))) SomeArray[2048];

Or if you are lazy, and want to risk it, just use the last page of flash and hope that your compiler doesn't put anything there (and then use a cast to access it).

dan10
Associate II
Posted on May 17, 2011 at 13:22

I am using the Keil uVision compiler. Sorry I didn't think to give that information.

I have tried just placing it at the end of the memory and casting it, but I would prefer to do this within the compilers knowledge.

Dan

st3
Associate II
Posted on May 17, 2011 at 13:22

Quote:

I would prefer to do this within the compilers knowledge.

It's really of no consequence to the Compiler - it's the Linker that needs to know...

dan10
Associate II
Posted on May 17, 2011 at 13:22

OK... I found something about changing the scatter files! but this was not for my processor, and I could not get it to work in my project.

Any information on scatter files?

st3
Associate II
Posted on May 17, 2011 at 13:22

Quote:

I could not get it to work in my project.

What did you try?

In what way(s) did it ''not work''?

Quote:

Any information on scatter files?

Probably best to ask Keil about that...?