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.

CCS: Initializing the Control Law Accelerator



Tool/software: Code Composer Studio

Looking at this one code line that is part of the initialization code for the control law accelerator  (part of the example project HVPM_Sensorless_CLA): 

Cla1Regs.MVECT1 = ((Uint16)Cla1Task1 - (Uint16)&Cla1Prog_Start);

 


I have two questions

1. How does the compiler translate typecasing a function name eg: (uint16)Cla1Task1 ? I would have used (uint16)&Cla1Task1 instead where the address of the function is used instead of the functions itself.

2. In order for this to work the ISR function Cla1Task1() must be located in L3 DPSARAM region (between address 0x9000h - 0xA000h), but I can't find the code / linker script that is actually placing the Cla1Task1 function in this RAM region in the first place. Where/how does this work?

  • Hi,

    I don't have a great answer for 1. It may be a linker symbol.

    For 2, Do you see the CLAProg section in the linker command file. It should be placed there.

    sal
  • Hello Sal,

    Thanks for responding. 

    I understand that the code must be placed in CLAprog, more like CLA1prog because the linker command file name is CLA1prog as below:

    memory{ page 0:

    ...RAML3     : origin = 0x009000, length = 0x001000     /* data RAM (L3) */.... }

    sections{...

    Cla1Prog : LOAD = FLASHC, /* Note for running from RAM the load and RUN can be the same */
                      RUN = RAML3,
                      LOAD_START(_Cla1funcsLoadStart),
                      LOAD_END(_Cla1funcsLoadEnd),
                      RUN_START(_Cla1funcsRunStart),
                      PAGE = 0

    ... }

    But I am more concerned with what part of the code is actually doing this placement? For example in order to place the Flash initialization function in ramfuncs the following line of code would be written:

    #pragma CODE_SECTION(InitFlash, "ramfuncs");

    Similarly I would expect a code as below that would place Cla1Task1 in CLAprog

    #pragma CODE_SECTION(Cla1Task1, "CLAprog");

    But I can't find this line of code anywhere in the project.

  • In this documentation for the C/C++ compiler "www.ti.com/.../spru514q.pdf", page 202 there is a line that says "Files that have a .cla extension are recognized by the compiler as CLA C files." So is it also possible that the linker automatically places this functions (code sections) within this file (extension *.cla) at the CLA1prog section automatically?

    That would explain the lack of explicit codes linker command

  • Hi,

    Yes, that is exactly what the code generation tools do.

    sal