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.
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.
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); }