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.

LAUNCHXL-F280049C: CLA EXAMPLE PROBLEM. TASKS WITH EVEN NUMBER DOESN'T WORK

Part Number: LAUNCHXL-F280049C


Hi.

I am trying to make CLA unit work. I added counter below the every statement. But it's strange that tasks with even number doesn't work.

void initCLA(void)
{
    /* Enable CLA clock */
    SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_CLA1);

    /* CLA Hard reset */
    CLA_performHardReset(CLA1_BASE);

    //
    // Copy the program and constants from FLASH to RAM before configuring
    // the CLA
    //
#if defined(_FLASH)
    memcpy((uint32_t *)&Cla1ProgRunStart, (uint32_t *)&Cla1ProgLoadStart,
        (uint32_t)&Cla1ProgLoadSize );
    memcpy((uint32_t *)&Cla1ConstRunStart, (uint32_t *)&Cla1ConstLoadStart,
        (uint32_t)&Cla1ConstLoadSize );
#endif //defined(_FLASH)

    //
    // CLA Program will reside in RAMLS0 and data in RAMLS1, RAMLS2
    //
    MemCfg_setCLAMemType(MEMCFG_SECT_LS0, MEMCFG_CLA_MEM_PROGRAM);
    MemCfg_setCLAMemType(MEMCFG_SECT_LS1, MEMCFG_CLA_MEM_DATA);
    MemCfg_setCLAMemType(MEMCFG_SECT_LS2, MEMCFG_CLA_MEM_DATA);
    MemCfg_setLSRAMMasterSel(MEMCFG_SECT_LS0, MEMCFG_LSRAMMASTER_CPU_CLA1);
    MemCfg_setLSRAMMasterSel(MEMCFG_SECT_LS1, MEMCFG_LSRAMMASTER_CPU_CLA1);
    MemCfg_setLSRAMMasterSel(MEMCFG_SECT_LS2, MEMCFG_LSRAMMASTER_CPU_CLA1);

//
// Suppressing #770-D conversion from pointer to smaller integer
// The CLA address range is 16 bits so the addresses passed to the MVECT
// registers will be in the lower 64KW address space. Turn the warning
// back on after the MVECTs are assigned addresses
//
#pragma diag_suppress=770

    //
    // Assign the task vectors and set the triggers for task 1 and 7
    //
    CLA_mapTaskVector(CLA1_BASE, CLA_MVECT_1, (uint16_t)&Cla1Task1);
    CLA_mapTaskVector(CLA1_BASE, CLA_MVECT_2, (uint16_t)&Cla1Task2);
    CLA_mapTaskVector(CLA1_BASE, CLA_MVECT_3, (uint16_t)&Cla1Task3);
    CLA_mapTaskVector(CLA1_BASE, CLA_MVECT_4, (uint16_t)&Cla1Task4);
    CLA_mapTaskVector(CLA1_BASE, CLA_MVECT_5, (uint16_t)&Cla1Task5);
    CLA_mapTaskVector(CLA1_BASE, CLA_MVECT_6, (uint16_t)&Cla1Task6);
    CLA_mapTaskVector(CLA1_BASE, CLA_MVECT_7, (uint16_t)&Cla1Task7);
    CLA_setTriggerSource(CLA_TASK_1, CLA_TRIGGER_SOFTWARE);
    CLA_setTriggerSource(CLA_TASK_2, CLA_TRIGGER_SOFTWARE);
    CLA_setTriggerSource(CLA_TASK_3, CLA_TRIGGER_SOFTWARE);
    CLA_setTriggerSource(CLA_TASK_4, CLA_TRIGGER_SOFTWARE);
    CLA_setTriggerSource(CLA_TASK_5, CLA_TRIGGER_SOFTWARE);
    CLA_setTriggerSource(CLA_TASK_6, CLA_TRIGGER_SOFTWARE);
    CLA_setTriggerSource(CLA_TASK_7, CLA_TRIGGER_SOFTWARE);


    //
    // Enable Tasks 1 and 7. Since task 7 is forced in software, we must
    // enable software forcing (IACKE)
    //
    CLA_enableTasks(CLA1_BASE, CLA_TASKFLAG_1);
    CLA_enableTasks(CLA1_BASE, CLA_TASKFLAG_2);
    CLA_enableTasks(CLA1_BASE, CLA_TASKFLAG_3);
    CLA_enableTasks(CLA1_BASE, CLA_TASKFLAG_4);
    CLA_enableTasks(CLA1_BASE, CLA_TASKFLAG_5);
    CLA_enableTasks(CLA1_BASE, CLA_TASKFLAG_6);
    CLA_enableTasks(CLA1_BASE, CLA_TASKFLAG_7);
    CLA_enableIACK(CLA1_BASE);

    //
    // The background task will be triggered by software; it shares
    // the same trigger source as task 8. Disable the hardware triggering
    // mechanism for the background task (if it is enabled) and then
    // set the trigger source for task 8 to 0 indicating a software
    // trigger.
    //
    // Enable the background task and start it. Enabling the background
    // task disables task 8.
    //
#pragma diag_warning=770
    CLA_setTriggerSource(CLA_TASK_8, CLA_TRIGGER_SOFTWARE);
    CLA_enableBackgroundTask(CLA1_BASE);
    CLA_startBackgroundTask(CLA1_BASE);



}

And this is what I call inside a loop.

void CLA_Task(void *CLAtaskParameter)
{
    for(;;)
    {
        if(xSemaphoreTake(testSemaphore_smph,portMAX_DELAY))
        {
            C2000_Var.semaphorecounter_i16++;
            CLA_forceTasks(CLA1_BASE, CLA_TASKFLAG_1);
            vTaskDelay(100);
            CLA_forceTasks(CLA1_BASE, CLA_TASKFLAG_2);
            vTaskDelay(100);
            CLA_forceTasks(CLA1_BASE, CLA_TASKFLAG_3);
            vTaskDelay(100);
            CLA_forceTasks(CLA1_BASE, CLA_TASKFLAG_4);
            vTaskDelay(100);
            CLA_forceTasks(CLA1_BASE, CLA_TASKFLAG_5);
            vTaskDelay(100);
            CLA_forceTasks(CLA1_BASE, CLA_TASKFLAG_6);
            vTaskDelay(100);
            CLA_forceTasks(CLA1_BASE, CLA_TASKFLAG_7);
            vTaskDelay(100);

        }
    }
}


And my debug screen.

  • I suspect the issue of every other counter appearing to be zero is related to the size of an int.

    • For CLA an int is 32-bits
    • For C28x an int is 16-bit

    To avoid ambiguity when sharing data between CLA and C28x, it is strongly recommended that you use type declarations that include size information (for example, int32_t and uint16_t which are defined in <stdint.h>).

    To debug this issue, please put a breakpoint in one of the even numbered tasks.  Make sure the CLA is connected and see if you hit the breakpoint.  From there step through the code to see what happens when the counter is incremented. 

    If you do not hit the breakpoint, then check the CLA setup (vectors are correct, tasks are enabled, etc..).

    Regards

    Lori

  • The main problem with CLA is I can't use the breakpoints in .cla file. The changing variable types didn't solve my problem. Actually I found very strange thing when I try to change my variables from counter to static. I declared them as

    t1 = 101

    t2 = 102

    t3 = 103

    t4 = 104

    t5 = 105

    t6 = 106

    t7 = 107

    But when I hit the debug button I saw this

    t1 = 101

    t2 = 0

    t3 = 102

    t4 = 0

    t5 = 103

    t6 = 0

    t7 = 104

    I really don't know what is going on but when I deleted the project and created a new one my problem fixed. I think this CLA thing is not a reliable module yet. I don't know what TI experts think. Still appriciate your help and I would like to learn what is the real problem.

  • Click here for more CLA FAQs and resources.

    Frozen said:
    The main problem with CLA is I can't use the breakpoints in .cla file.

    On the F28004x CLA Type 2 there are two ways to set breakpoints in CLA code.  Refer to the device specific TRM.  Search for MDEBUGSTOP.

    http://www.ti.com/lit/sprui33

    Frozen said:
    Actually I found very strange thing when I try to change my variables from counter to static. I declared them as

    The code shown is initialization, not declaration. The declaration should use C99 datatypes in order for the size of the variable to be unambiguous.

    This blog article describes it well: https://barrgroup.com/Embedded-Systems/How-To/C-Fixed-Width-Integers-C99

    For example

    //
    // in the shared header file and main .c file
    // Does not indicate the size of the variable
    // An unsigned int on C28x is 16-bit and an unsigned int on CLA is 32-bits
    //
    unsigned int t0; unsigned int t1; // // Instead use C99 data types with size information // #include <stdint.h> uint16_t t0; uint16_t t1;

    Regards, Lori