CARM User's Guide

Discontinued

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

typeis the C data type of the variable.
variable-nameis the name of the variable.
addressis the address where the variable is stored.
valueis 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;