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.

TMS320F28035: CLA Task Clock Cycle

Part Number: TMS320F28035
Other Parts Discussed in Thread: CONTROLSUITE

Dear all,

Is there any way to learn how many clock cycles last a CLA task? For an ISR which is fun by CPU, I store the time at the beginning of the ISR and at the end of the ISR and I subtract the first time from the second time, In this way, I can find how many clock cycles last that ISR. However, in CLA task, when I apply the same procedure, it gives me nothing.

I would be appreciated if someone show me a way to solve this. Thank you in advanced.

Kind Regards,

Merih.

  • interrupt void EPWM1_INT_ISR() // Try this :
    { STRT_CHRONO; // Memorize timer count at start ( e.g CpuTimer1Regs.TIM.all)
    Cla1ForceTask4(); // This is where CLA-Task4 starts
    ....
    }

    interrupt void CLA1_INT4_ISR() // This is where CLA-Task4 ends
    { STOP_CHRONO; // Memorize timer count at stop and use the difference
    ...
    }
  • Hi Ibrahim,

    Thank you for the reply.

    I use "clk1 = CpuTimer0Regs.TIM.all;" line to store the time both in CPU and CLA. I get a value in CPU interrupt but CLA gives me nothing. I think this is because of that I am using CPU timer both in CPU and CLA. Which timer should I use for CLA?

    Thank you again.

    Kind Regards,
    Merih
  • Hi Merih,

    The CLA on the 28035 does not have access to the timers, but the idea is a correct one. You will have to use the timer from a spare EPwm module. The procedure for this is documented in the firmware user's guide (ti/controlsuite/device_support/f2803x/version/doc/...UG.pdf, section 5.7). Here is the exerpt

    5.7.2 Benchmarking
    The CLA does not support the clock function and therefore it is not possible to get a direct cycle
    count of a particular task. The user can configure the time base module on an ePWM to keep track
    of the execution time of a task
    Setup the time base of ePWM1(or any ePWM) to run at SYSCLKOUT in the up-count mode as
    shown below:
    void InitEPwm(void)
    {
    // Setup TBCLK
    EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP; // Count up
    EPwm1Regs.TBPRD = 0xFFFF; // Set timer period
    EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Disable phase loading
    EPwm1Regs.TBPHS.half.TBPHS = 0x0000; // Phase is 0
    EPwm1Regs.TBCTR = 0x0000; // Clear counter
    EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; // Clock ratio to SYSCLKOUT
    EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV1;
    }
    
    Proceed to define two macros READ_CLOCK and RESTART_CLOCK, the former to freeze the
    ePWM timer and copy the elapsed time to a variable, and the latter to restart the ePWM timer.
    #define READ_CLOCK(X) __meallow();\
    EPwm1Regs.TBCTL.bit.CTRMODE = TB_FREEZE;\
    X = EPwm1Regs.TBCTR;\
    __medis();
    #define RESTART_CLOCK __meallow();\
    EPwm1Regs.TBCTL.bit.CTRMODE = TB_FREEZE;\
    EPwm1Regs.TBCTR = 0;\
    EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP;\
    __medis();
    Define a variable e.g. ulCycleCount to hold the cycle count
    #pragma DATA_SECTION(ulCycleCount,"Cla1ToCpuMsgRAM");
    unsigned long ulCycleCount;
    Place the macro RESTART_CLOCK at the beginning of a task to restart the ePWM timer and place
    READ_CLOCK at the end of the task to read the value of the timer. The elapsed time will be give
    you the cycle count plus a minimal overhead from the two macros
    __interrupt void Cla1Task1 ( void )
    {
    //Local Variables
    float a;
    __mdebugstop();
    RESTART_CLOCK;
    a = 10;
    ...
    ...
    ...
    READ_CLOCK(ulCycleCount);
    }

  • Hi Melih;
    CLA´s access to resources is limited; that´s the reason why you get ´nothing´ (zero) when you try to read timer from the CLA.
    The example-code should run 'ONLY ON CPU'. There is no access necessary from within CLA!
    // ------------------------------------------------------------------------------------------------------------------------------------------
    // -- Do not forget to correctly set up an enable both interrupts ----
    //
    interrupt void EPWM1_INT_ISR() // Try this :
    { STRT_CHRONO; // Memorize timer count at start ( e.g CpuTimer1Regs.TIM.all)
    Cla1ForceTask4(); // This is where CLA-Task4 starts
    ....
    }

    interrupt void CLA1_INT4_ISR() // This is where CLA-Task4 ends
    { STOP_CHRONO; // Memorize SAME timer count ( e.g CpuTimer1Regs.TIM.all) at stop and use the difference
    ...
    }
    // ------------------------------------------------------------------------------------------------------------------------------------------
    Regards