const DATA at absolute address in CODE seg

Hi all, My goal is to put a few constants in the code segment at compile time so they are stored in the program flash when the SiLabs 'F122 is initialized via JTAG.

const UCHAR code ucTBD = TBD_VAL;

seems to work but I'd like to put the data at a known address so I can read it explicitly with a MOVC-type flash read. But

const UCHAR code ucTBD _at_ 0x6000 = TBD_VAL;

is unacceptable because an absolute specifier is illegal.

Without the "_at_", the linker puts the data down with the ISR vectors but I need it to reside in flash space that I am comfortable modifying.

It seems to work if I declare ucTBD inside a function and assign an absolute location to that function. Is that an acceptable and reliable method?

Thanks in advance for any advice,
John

Ref:
typedef unsigned char UCHAR;
#define TBD_VAL (0x00)

Parents
  • C51 doesn't let you use both _at_ and an initializer for the same variable. This feature is often requested on the board.

    You can use the initializer in the compiler, and then use the linker to place the variable where you want it. See the "Segment And Memory Location" section of the linker manual.

    You may need to declare the variables you want to manually locate in a separate C file to ensure that they get their very own segment name.

Reply
  • C51 doesn't let you use both _at_ and an initializer for the same variable. This feature is often requested on the board.

    You can use the initializer in the compiler, and then use the linker to place the variable where you want it. See the "Segment And Memory Location" section of the linker manual.

    You may need to declare the variables you want to manually locate in a separate C file to ensure that they get their very own segment name.

Children
More questions in this forum