Sometimes it is useful to be able to place a specific variable at a specific location in memory, rather than relying upon the automatic placement carried out by default by the linker. For example, you might need to place a buffer variable accessed by a peripheral into your system to a know location in RAM.
Placement using the memory configuration editor
By default the LPCXpresso IDE provides a standard memory layout for known MCUs. This defines the locations of the available banks of RAM, and any internal flash. If the variable you want to place needs to be located as the only variable in a particular bank of the defined RAM, then you can simply use the attribute macros provided by the "cr_section_macros.h" header file, as described in the FAQ:
However, if you need a finer level of granuality, then it is then possible to edit the predefined memory layout for your particular project using the "Memory Configuration Editor" (sometimes referred to as simply the "Memory Editor") - often to add details of external flash devices. For more details, please see the LPCXpresso User Guide.
Thus you can use the Memory Configuration Editor to divide up (and rename) the existing banks of RAM. This then allows you to provide a specific named block of RAM into which to place the variable that you need at a specific address, again by using the attribute macros provided by the "cr_section_macros.h" header file.
Placement by modifying the linker script file
In some situations rather than using the managed linker script mechanism, you may wish you wish to place data at a known address when you are maintaining the linker script by hand. In such circumstances you can use the following technique to place your data: