AnsweredAssumed Answered

Writing const data to hard address

Question asked by Sergey Gagiev on Jun 9, 2009
Latest reply on Jun 11, 2009 by Pascal Irrle

Hi,

I write next code:

 

#pragma define_section config_data1 ".x_config1" RW  //  
#pragma define_section config_data2 ".x_config2" RW  //
//
#pragma section config_data1 begin
const struct cfg sConfig1 =
{
CFG_VALID_KEY,
(FRAC16(1/1.074)),  
(316*8)   
};
#pragma section config_data1 end
//
#pragma section config_data2 begin
struct cfg sConfig2;
#pragma section config_data2 end

 

Then, I insert to linker command file new memory segments x_CFG_1 & x_CFG_2:

 

MEMORY {
        # I/O registers area for on-chip peripherals
        .x_Peripherals (RW)   : ORIGIN = 0x0C00, LENGTH = 0
        .x_CoreRegs    (RW)   : ORIGIN = 0xFF80, LENGTH = 0

        # List of all sections specified in the "Build options" tab
        #Internal vector boot area.
        .p_Interruptsboot  (RWX) : ORIGIN = 0x00008000, LENGTH = 0x0004
        .p_Interrupts  (RWX) : ORIGIN = 0x00000000, LENGTH = 0x00000080
        .p_Code  (RWX) : ORIGIN = 0x00000080, LENGTH = 0x00001F80
        .x_Data  (RW) : ORIGIN = 0x00000040, LENGTH = 0x000003C0
        .x_CWRegisters  (RW) : ORIGIN = 0x00000030, LENGTH = 0x00000010

        #Other memory segments - size of .x_internal_ROM = 2048 - (.x_CFG_1 + .x_CFG_2)
        .x_internal_ROM  (RW)  : ORIGIN = 0x00001000, LENGTH = 0x0600
        .p_internal_RAM  (RWX) : ORIGIN = 0x00007C00, LENGTH = 0x0400
  #Configuration areas from data flash
  .x_CFG_1 (RW) : ORIGIN = 0x00001600, LENGTH = 0x100
  .x_CFG_2 (RW) : ORIGIN = 0x00001700, LENGTH = 0x100
}

 

and sections:

 

   #******************* Configuration data flash sections         
        .x_config1 :
        {
         mcl.c (FsConfig1)
        } > .x_CFG_1
       
  .x_config2 :
        {
       
        } > .x_CFG_2
       
        #****************** End Configuration data flash sections

 

Linker warnings:

 

FsConfig1 (.x_config1) in file mcl.c is referenced but has not been written

check your linker command file

 

idem for sConfig2

 

How can I write FsConfig1 to section .x_config1 under compiling?

Outcomes