This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Creating second .data and .cinit section for calibration purposes with TMS570

Other Parts Discussed in Thread: TMS570LS1227

Hello.

I would like to create a second ".data" section for initialized global variables which I want to calibrate (modify whlie the MCU is running). In other words I wish for "calibratable" global variables to be located in a contiguous block of memory. I also require a second, separate".cinit " section for the initial values of these calibration variables which will be placed in EEPROM memory. Calibratable variables will ideally be marked with a corresponding #pragma or  __attribute__ ((section ( tag in the code

Is this possible and if so what changes do I need to make to the linker script to enable this?

I am using a TMS570LS1227 with CCS v6 and TI v5.2.5 compiler.

Your help and advice is appreciated.

Many thanks,

James Wiblin.

  • I must be missing something.  Other than this ...

    James Wiblin said:
    global variables to be located in a contiguous block of memory

    everything in your description of these calibration variables matches how ordinary C global variables work.  So, what am I missing?

    Thanks and regards,

    -George

  •  I would like certain calibratable variables to be placed in their own block of ram, separate from the rest of the global variables, if that makes sense? That way I can write ONLY my calibration variables into the EEPROM as a block when I want to save them. And load them again from the EEPROM on start up. 

    As you said the behaviour should be identical to ordinary C global variables, except I want certain ones to reside in a particular section of ram and a particular section of flash (EEPROM) :).

    If I create a section named: .calib_ram and then use this when initiating variable var_x: var_x = 25  __attribute__((section(".calib_ram"))); I can use the linker script to place var_x in section calib_ram. But how can I create a separate flash section which stores the initial value of var_x (25) away from all the other globals in .cinit?

  • James Wiblin said:
    If I create a section named: .calib_ram and then use this when initiating variable var_x: var_x = 25  __attribute__((section(".calib_ram"))); I can use the linker script to place var_x in section calib_ram.

    That makes sense.

    James Wiblin said:
    how can I create a separate flash section which stores the initial value of var_x (25) away from all the other globals in .cinit?

    There is no built-in feature of the tools to support that.  

    Thanks and regards,

    -George

  • Probably the best you could do would be to create a const table of initial values for the "calibratable" variables, and have your program use this table at program start to initialize the variables (perhaps memcpy?). Place this const table in EEPROM, then change the values in EEPROM as you like.
  • Ok. Thank you both for clarifying things :) What archaeologist suggested is what I originally had in mind, but I thought it might be possible via the linker script.