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.

alternative to IAR's @ <address> syntax for CCS?

I'm using IAR Kickstart (the free version)

  IAR C/C++ Compiler for MSP430
  4.20.1 [Kickstart] (4.20.1.30017)

and I've setup code to calculate the temperature using the ADC and it's calibration values. 

To support this, I use this syntax (I'm sure I found it in an example somewhere):

  // ADC Cal Tag       is @0x1A14 - 1 bytes
  // ADC Cal Length   is @0x1A15 - 1 bytes
  // ADC Gain Factor   is @0x1A16 - 2 bytes
  // ADC Offset          is @0x1A18 - 2 bytes
  // ADC 1.5V Ref Factor is @0x1A1A - 2 bytes
  __no_init unsigned short cal_adc_15T30 @ 0x1A1C;
  __no_init unsigned short cal_adc_15T85 @ 0x1A1E;

It's probably not the "right way" to do it, but it worked just fine.  I know I'm going to be on the MSP430F54xx.

Now I'm having to switch over to CCSv4, which has the compiler:

   MSP430 Evaluation C/C++ Compiler v3.2.1
   Build Number 1JE6M-KDADEMDK-RTARQ-TAV-ZACIF_T_S_R

I've looked but I haven't found any alternative syntax like the IAR Kickstart
compiler has. Do I need to do something like:

   unsigned short cal_adc_15T30 = *((unsigned short *)0x1A1C);


Or maybe add something to the msp430f54x.cmd linker file?  Or is there a more acceptable way to do this?

Thanks,
Pete

  • Hi Pete,

    data placement at an absolute location is implement different in CCS than in IAR! Have a look at the Code Composer Studio V4 User's Guide for MSP430 (http://focus.ti.com/lit/ug/slau157k/slau157k.pdf). On page 26 you will find a detailed description how to do it.

    Rgds
    aBUGSworstnightmare

     

     Data Placement at an Absolute Location

    The scheme implemented in the IAR compiler using either the @ operator or the #pragma location

    directive is not supported with the CCS compiler:

    /* IAR C Code */
    __no_init char alpha @ 0x0200; /* Place ‘alpha' at address 0x200 */
    #pragma location = 0x0202 const int beta;

     

    If absolute data placement is needed, this can be achieved with entries into the linker command file, and then declaring the variables as extern in the C code:

    /* CCS Linker Command File Entry */
    alpha = 0x200;
    beta = 0x202;
    /*CCS C Code */
    extern char alpha;
    extern int beta;

    The absolute RAM locations must be excluded from the RAM segment; otherwise, their content may be overwritten as the linker dynamically allocates addresses. The start address and length of the RAM block must be modified within the linker command file. For the previous example, the RAM start address must be shifted 4 bytes from 0x0200 to 0x0204, which reduces the length from 0x0080 to 0x007C (for an MSP430 device with 128 bytes of RAM):

    /* CCS Linker Command File Entry */

    /****************************************************************************/
    /* SPECIFY THE SYSTEM MEMORY MAP */
    /****************************************************************************/

    MEMORY /* assuming a device with 128 bytes of RAM */
    { ...

    RAM :origin = 0x0204, length = 0x007C /* was: origin = 0x200, length = 0x0080 */

    ... }

    The definitions of the peripheral register map in the linker command files (lnk_msp430xxxx.cmd) and the device-specific header files (msp430xxxx.h) that are supplied with CCS are an example of placing data at absolute locations.

    Note: When a project is created, CCS copies the linker command file corresponding to the selected MSP430 derivative from the include directory (<Installation Root>\tools\compiler\MSP430\include) into the project directory. Therefore, ensure that all linker command file changes are done in the project directory. This allows the use of project-specific linker command files for different projects using the same device.