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;
const UCHAR code ucTBD _at_ 0x6000 = TBD_VAL;
typedef unsigned char UCHAR; #define TBD_VAL (0x00)
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.
"This feature is often requested on the board." A common reason is for a version code - placed at a known location so that it can easily be found on a PROM programmer. However, I don't see anything in the original post that actually requires fixing at an absolute address. Perhaps John could explain?
View all questions in Keil forum