3

I have what seems to be a simple problem, and I am sure that I have solved it before, but I am having trouble finding the answer again so hopefulley there is someone out there who can point me in the right direction

I have an area of memory that i would like to "reserve" for a specific variable in my code.

I know I can do this by editing the linker script, and removing my block of data from the rom section, to ensure that program code is not written the specific address - but rather than editing the script I remember doing this in c code a long time ago. I did it using a pragma or something similiar and from memory it looked something like this (the code is not right, but this is vaguely what i remember!)

"#pragma _address @0x00040000 char mydata[1024]; "

Which would reserve 1024 bytes of data at the address 0x00040000.

Does anyone know the correct format for the above code?

For context - I am writing embedded C applications, using flash based microprocessors. The area is flash and I would like to store flash configuration data (generated by my program) there. To use the flash I need to align my data in the correct block, so i need to specify the address. What I would like to do is reserve an area of flash that wont be filled with my program code, so that I can fill it with my configuration data.

Thanks for your help!

Stevo

Stevo
  • 31
  • 1

1 Answers1

2

The #pragma directive has implementation-defined keywords, so your answer depends on your compiler. Recommend consulting your compiler's manual.

dchellaram
  • 58
  • 3