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.

TMS320F28377S: How to share /reuse code between main controller and CLA

Genius 5910 points

Part Number: TMS320F28377S
Other Parts Discussed in Thread: C2000WARE-DIGITALPOWER-SDK, TIDM-1000, TIDM-1007, TIDA-01604

How do I reuse code between the main and CLA?

Is there a smart way to combine file so I can use it on both platforms?

Thanks,

 EVS

  • Hi,

    I am not sure exactly what you are asking.

    The C28x and the CLA require different compilers since they have different ISA. If you want to use code that can be compiled for each, I think you would have to put it in a header file and share include that header file in a .c (C28x) file and a .cla (CLA) file.

    Otherwise, .c files get compiled for C28 and .cla files get compiled for CLA.

    Hope this helps,
    sal
  • Sal Pezzino said:
    Hi,

    I am not sure exactly what you are asking.

    The C28x and the CLA require different compilers since they have different ISA. If you want to use code that can be compiled for each, I think you would have to put it in a header file and share include that header file in a .c (C28x) file and a .cla (CLA) file.

    Otherwise, .c files get compiled for C28 and .cla files get compiled for CLA.

    Hope this helps,
    sal

    I have a library with functionality I also like to use in the CLA. So that there is one source tree that I have to maintain. This in impossible with the CLA.

    I can't use .c file in the CLA but when I copy or include the code to .cla file I got this error message:

    error #10056: symbol "_IIR_CalcFOCoefficients" redefined: first defined in "./CLA/IIR_Filters.obj"

    So I have to copy the the code to a CLA file and rename all the call to get it working.

    So the CLA and main compiler are separate but naming can't be the same.

    I tried to go around this problem with this:

    --- IIR_Filters.cla file ----

    #include "CLAmath.h"
    #include "Motorctrl/IIR_Filters.h"
    #define cos     CLAcos
    #define sin     CLAsin
    #define exp     CLAexp

    #include "Motorctrl/IIR_Filters.c"

    But it didn't work.

  • EVS,

    I agree with sal, the only way you can do this is through a header file, and every thing being static inline function.

    Then the C28x compile it when it sees the call on the C28x and CLA compiler will compile it when it sees the call on the CLA.

    We have some examples of doing this,

    see:
    C2000Ware-digitalpower-sdk

    solution TIDM-1000, TIDM-1007 and TIDA-01604

    all of them use the same source and can run on C28x and CLA.
  • If you really have a .lib built separately you will have to build them with different names for CLA or C8x , you can use a @ifdef thing for this. You will see that in the reference code i mentioned above as well.