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.

CCS/RM57L843: Code execution measurement using PMU not working.

Part Number: RM57L843


Tool/software: Code Composer Studio

Hello,

I'm trying to measure code execution time using PMU, I followed steps mentioned in "Execution Time Measurement for Hercules™ ARM® Safety MCUs" pdf.

But every time I get zero counter value. I'm using pmuCOUNTER0 to measure cycles.

I also checked the memory view, there also im getting 0 value.

Is there something i'm missing to implement in the code.
Please let me know how to resolve this issue.


Regards,
Shantanu S.





Bellow is code i am using to measure cycles:

#include "HL_sci.h"
#include "HL_sys_core.h"
#include "HL_sys_pmu.h"

#include "HL_sys_common.h"

volatile uint32_t cycles_PMU_start, cycles_PMU_end, cycles_PMU_measure, cycles_PMU_comp, cycles_PMU_code;
volatile float time_PMU_code;

int main(void)
{

    //------ init ---------
    _pmuInit_();
    _pmuEnableCountersGlobal_();
    _pmuSetCountEvent_(pmuCOUNTER0, PMU_CYCLE_COUNT); // PMU_INST_ARCH_EXECUTED

    //---- start -----
    _pmuResetCounters_();
    _pmuStartCounters_(pmuCOUNTER0);
    cycles_PMU_start = _pmuGetEventCount_(pmuCOUNTER0);

    asm(" NOP");
    asm(" NOP");
    asm(" NOP");
    asm(" NOP");
    asm(" NOP");
    asm(" NOP");
    asm(" NOP");
    asm(" NOP");
    asm(" NOP");
    asm(" NOP");

    //------ stop -----
    _pmuStopCounters_(pmuCOUNTER0);
    cycles_PMU_end = _pmuGetEventCount_(pmuCOUNTER0);
    cycles_PMU_measure = cycles_PMU_end - cycles_PMU_start;

    // ----- compensation -----
    _pmuResetCounters_();
    _pmuStartCounters_(pmuCOUNTER0);
    cycles_PMU_start = _pmuGetEventCount_(pmuCOUNTER0);

    _pmuStopCounters_(pmuCOUNTER0);
    cycles_PMU_end = _pmuGetEventCount_(pmuCOUNTER0);
    cycles_PMU_comp = cycles_PMU_end - cycles_PMU_start;

    //------- time cal -------
    cycles_PMU_code = cycles_PMU_measure - cycles_PMU_comp;
    time_PMU_code = cycles_PMU_code / (300.00); // time_code [us], f_HCLK [MHz]

 while(1);
}