Storing the value in particular memory location using GCC


TitleStoring the value in particular memory location using GCC
How can I store a value in a particular memory location? 
This FAQ will explain about how to store a particular value in a memory location. For example consider you want to store 0x0A in the particular memory location 0x1FE.

You can use __attribute to store data in a particular location. 

unsigned char memory=0x0A;

2. G
o to Project-> Project Properties->Toolchain-> AVR/GNU Linker-> Miscellaneous, and add the linker flag as “-Wl,--section-start=.version=0x1FE”.

User-added image

3. Build the Project. The memory section will start at 0x1F and value (0x0A) will be stored.

Note: U
ncheck the option garbage collect from Project-> Project Properties->Toolchain-> AVR/GNU Linker->Optimization. 

URL NameStoring-the-value-in-particular-memory-location-using-GCC

Powered by