Keil Logo

ARMCC: Placing Code at an Absolute Address Using the Keil µVISION IDE


Information in this article applies to:

  • MDK-ARM All Versions

QUESTION

How can I place a piece of code, or constant data, at a fixed location in my program's binary, using the MDK-ARM toolchain?

ANSWER

Your µVision project allows you to explicitly place code or constant data at a fixed location you specify.

To place a module containing code or constants at a specific location:

  1. Declare a new ROM space in the Options for Target — Target setup page. This new declaration should start at the address where you want your code or constant to begin. For example, assuming you want your module located at 0x20000 in Flash memory that shouldn't exceed 0x1000 bytes, enter the following in the ROM1 boxes of the Read/Only Memory Area:
  2. Put the code or constant data you want to place in a separate source file, and add that file to your project.
  3. In the Project window, right-click the source file name containing the code or data to be placed to display the Options for File dialog for that source file.
  4. In the Memory Assignment section, set the Code/Const box to the ROM space you just declared. In this example, select ROM1.
  5. Click OK to save your changes.

µVision uses the Target and Memory Assignment settings to create a scatter (.SCT) file for the target, if you didn't manually create or specify one. The scatter file tells the linker how to build your target application.

For more information about placing code using a scatter file, see: Example of how to explicitly place a named section with scatter-loading

MORE INFORMATION

SEE ALSO

ARM: LOCATING VARIABLES AT ABSOLUTE MEMORY ADDRESSES

FORUM THREADS

The following Discussion Forum threads may provide information related to this topic.

Last Reviewed: Monday, November 5, 2018


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.