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.

CLA static task variables

I am working on a program that utilizes the CLA (F28069).  Originally, I had my algorithm running on the C28x core, and I used a lot of static variables within a function.  They would be initialized once, then updated every time the function was called.

void foo(void) {
static int a=0;
static int b=0;
//... and so on
a++;
b++;
//... and so on
}

In order to port this over to the CLA, I realize I need to declare them as global variables in shared CLA2CPU RAM and initialize them in task8.  However, there are too many variables to fit in this RAM location.

#pragma DATA_SECTION(a, "ClaToCpuMsgRAM");
#pragma DATA_SECTION(b, "ClaToCpuMsgRAM");
//... and so on

interrupt void Cla1Task1 (void)
{
//do stuff with a, b, ... and so on
}

interrupt void Cla1Task8 (void)
{
//initialize a, b, ... and so on
}

Within the CLA, I'd like to have the functionality of a static variable that I can update every time the task is run and have it retain it's value.  But I'd like to do this without having to declare it as a global variable in shared CLA2CPU ram.  I don't necessarily need the C28x core to have access to it.  I'd also like to still be able to initialize it in task8.  Is this possible?

Can I just declare them as static variables within the .cla file and use them in task1 and initialize them in task8?

static int a;
static int b;
//... and so on
interrupt void Cla1Task1 (void)
{
//do stuff with a, b, ... and so on
}
interrupt void Cla1Task8 (void)
{
a=0;
b=0;
//... and so on
}

Also, if implemented in this way, where are these variables stored??? In CLA scratchpad?

  • So after some investigation, I was able to get it to work as described above, but I had to add sections .bss_cla and .const_cla to my cmd file.

    Here is my .cmd file for reference.  Please feel free to comment on it and point out if you see any problems.

    /*** User Configurable Options ***/
    #define USE_CLA_C    1      /* 1 = Using CLA C-compiler, 0 = ASM only */
    
    _Cla1Prog_Start = _Cla1funcsRunStart;
    -heap 0x400
    -stack 0x400
    
    /* Define size for the CLA scratchpad area that will be used
       by the CLA compiler for local symbols and temporary variables; Also force
       references to the special symbols that mark the scratchpad area. */
    
    #if USE_CLA_C == 1
       CLA_SCRATCHPAD_SIZE = 0x100;
       --undef_sym=__cla_scratchpad_end
       --undef_sym=__cla_scratchpad_start
    #endif
    
    MEMORY
    {
    PAGE 0:    /* Program Memory */
       BEGIN_M0           : origin = 0x000000, length = 0x000002     /* Part of M0SARAM - used for "Boot to M0" bootloader mode */
       L3DPSARAM          : origin = 0x009000, length = 0x001000     /* L3 DPSARAM, CSM secure, CLA Prog RAM */
       L4SARAM            : origin = 0x00A000, length = 0x002000     /* L4 SARAM, CSM secure */
       OTP            (R) : origin = 0x3D7800, length = 0x000400     /* OTP */
       FLASH_ABCDEFGH (R) : origin = 0x3D8000, length = 0x01FF80     /* FLASH, All sectors combined */
       CSM_RSVD       (R) : origin = 0x3F7F80, length = 0x000076     /* Part of FLASH Sector A - reserved when CSM is in use */
       BEGIN_FLASH    (R) : origin = 0x3F7FF6, length = 0x000002     /* Part of FLASH Sector A - used for "Jump to flash" bootloader mode */
       PASSWORDS      (R) : origin = 0x3F7FF8, length = 0x000008     /* Part of FLASH Sector A - CSM password locations */
       FPUTABLES      (R) : origin = 0x3FD860, length = 0x0006A0     /* Part of Boot ROM */
       IQTABLES       (R) : origin = 0x3FDF00, length = 0x000B50     /* Part of Boot ROM */
       IQTABLES2      (R) : origin = 0x3FEA50, length = 0x00008C     /* Part of Boot ROM */
       IQTABLES3      (R) : origin = 0x3FEADC, length = 0x0000AA     /* Part of Boot ROM */
       RESET          (R) : origin = 0x3FFFC0, length = 0x000002     /* part of Boot ROM */
    
     PAGE 1 :   /* Data Memory */
       M0SARAM            : origin = 0x000002, length = 0x0003FE     /* M0 SARAM */
       M1SARAM            : origin = 0x000400, length = 0x000400     /* M1 SARAM */
       CLAMSGRAM1         : origin = 0x001480, length = 0x000080     /* Part of PF0 - CLA to CPU Message RAM */
       CLAMSGRAM2         : origin = 0x001500, length = 0x000080     /* Part of PF0 - CPU to CLA Message RAM */
       L0DPSARAM          : origin = 0x008000, length = 0x000800     /* L0 DPSARAM, CSM secure, CLA Data RAM 2 */
       L1DPSARAM          : origin = 0x008800, length = 0x000400     /* L1 DPSARAM, CSM secure, CLA Data RAM 0 */
       L2DPSARAM          : origin = 0x008C00, length = 0x000400     /* L2 DPSARAM, CSM secure, CLA Data RAM 1 */
       L5DPSARAM          : origin = 0x00C000, length = 0x002000     /* L5 DPSARAM, DMA RAM 0 */
       L6DPSARAM          : origin = 0x00E000, length = 0x002000     /* L6 DPSARAM, DMA RAM 1 */
       L7DPSARAM          : origin = 0x010000, length = 0x002000     /* L7 DPSARAM, DMA RAM 2 */
       L8DPSARAM          : origin = 0x012000, length = 0x002000     /* L8 DPSARAM, DMA RAM 3 */
    }
    
     
    SECTIONS
    {
    /*** Compiler Required Sections ***/
    
      /* Program memory (PAGE 0) sections */
       .text              : > FLASH_ABCDEFGH,        PAGE = 0
       .cinit             : > FLASH_ABCDEFGH,        PAGE = 0
       .const             : > FLASH_ABCDEFGH,        PAGE = 0
       .econst            : > FLASH_ABCDEFGH,        PAGE = 0
       .pinit             : > FLASH_ABCDEFGH,        PAGE = 0
       .reset             : > RESET,                 PAGE = 0, TYPE = DSECT  /* We are not using the .reset section */
       .switch            : > FLASH_ABCDEFGH,        PAGE = 0
    
      /* Data Memory (PAGE 1) sections */
       .bss               : > M0SARAM,               PAGE = 1
       .ebss              : > M0SARAM,               PAGE = 1
       .cio               : > M0SARAM,               PAGE = 1
       .stack             : > M1SARAM,               PAGE = 1
       .sysmem            : > M1SARAM,               PAGE = 1
       .esysmem           : > M1SARAM,               PAGE = 1
    
       .bss_cla           : > L2DPSARAM,             PAGE = 1
       .const_cla         : > L2DPSARAM,             PAGE = 1
    
    /*** User Defined Sections ***/
       codestart          : > BEGIN_FLASH,           PAGE = 0                /* Used by file CodeStartBranch.asm */
       dmaMemBufs         : > L5DPSARAM,             PAGE = 1                /* Link to DMA accessible memory */
       csm_rsvd           : > CSM_RSVD,              PAGE = 0                /* Used by file Passwords.asm */
       passwords          : > PASSWORDS,             PAGE = 0                /* Used by file Passwords.asm */
       ClaToCpuMsgRAM     : > CLAMSGRAM1,            PAGE = 1                /* Link to PF0 - CLA Message RAM */
       CpuToClaMsgRAM     : > CLAMSGRAM2,            PAGE = 1                /* Link to PF0 - CLA Message RAM */
    
       /* Section secureRamFuncs used by file Flash.c. */
       secureRamFuncs     :   LOAD = FLASH_ABCDEFGH, PAGE = 0                /* Load to flash, run from CSM secure RAM */
                              RUN = L4SARAM,         PAGE = 0
                              LOAD_START(_secureRamFuncs_loadstart),
                              LOAD_SIZE(_secureRamFuncs_loadsize),
                              RUN_START(_secureRamFuncs_runstart)
    
       /* Section Cla1Prog used by file Cla.c */
       Cla1Prog           :   LOAD = FLASH_ABCDEFGH, PAGE = 0                /* Load to flash, run from CLA Prog RAM */
                              RUN = L3DPSARAM,       PAGE = 0
                              LOAD_START(_Cla1funcsLoadStart),
                              LOAD_END(_Cla1funcsLoadEnd),
                              LOAD_SIZE(_Cla1funcsLoadSize),
                              RUN_START(_Cla1funcsRunStart)
    
       CLA1mathTables     :   LOAD = FLASH_ABCDEFGH, PAGE = 0                /* Load to flash, run from CLA Prog RAM */
                              RUN = L0DPSARAM,       PAGE = 1
                              LOAD_START(_Cla1mathTablesLoadStart),
                              LOAD_END(_Cla1mathTablesLoadEnd),
                              LOAD_SIZE(_Cla1mathTablesLoadSize),
                              RUN_START(_Cla1mathTablesRunStart)
    
    #if USE_CLA_C == 1
       CLAscratch         : { *.obj(CLAscratch)                              /* Scratchpad memory for the CLA C Compiler */
                              . += CLA_SCRATCHPAD_SIZE;
                              *.obj(CLAscratch_end)
                            } > L2DPSARAM,           PAGE = 1
    #endif
    /*** Math Tables ***/
    
       FPUmathTables      : > FPUTABLES,             PAGE = 0, TYPE = NOLOAD
    /*** IQmath Sections ***/
       IQmathTables       : > IQTABLES,              PAGE = 0, TYPE = NOLOAD
       IQmath             : > FLASH_ABCDEFGH,        PAGE = 0
    }