Keil Logo

Absolute Variable Location

Variables in your C program may be located at absolute memory locations by using the __at keyword.

type variable-name __at address <[>= value<]>;

Where

type is the C data type of the variable.
variable-name is the name of the variable.
address is the address where the variable is stored.
value is the value assigned to the variable.

The __at keyword only applies to variables. It may not be used with function definitions.

The following example demonstrates how to locate several different variable types using the __at keyword.

struct link
  {
  struct link idata *next;
  char code *test;
  };

struct link list [100] __at 0x00014000;    /* list at 0x00014000 */

Use the following external declaration if you declare variables using the __at keyword in one source module and access them in another.

struct link
  {
  struct link idata *next;
  char        code  *test;
  };

extern struct link list [100];    /* list at 0x00014000 */

Note

  • To access memory-mapped peripherals using variables declared with the __at keyword, use the volatile keyword to ensure that the C compiler does not optimize out necessary memory accesses. For example:
    volatile unsigned char reg1 __at 0x00008000;
    
  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.