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.

[RM57L LaunchPad] Execution Time Measurement



Dear community,

I'd like to measure the execution time of a computation routine on RM57L LaunchPad. I followed a PDF tutorial on "execution time measurement", used the PMU to measure the code. And I have several questions regarding the tutorial:

Q1: Could I set f_HCLK to be 330 MHz, that is, the maximum frequency?

    /* -- Code Cycles / Run Time Calculations -- */
#if PMU_Cycle
    cycles_PMU_code = cycles_PMU_measure - cycles_PMU_comp;
    time_PMU_code = cycles_PMU_code / (f_HCLK * loop_count_max); // time_code [us], f_HCLK [MHz]
    printf("Total time taken by CPU: %.2fus\n", time_PMU_code);
#endif //PMU_Cycle

I found a post related to the requirement, in which f_HCLK is only a third of the maximum frequency.

https://e2e.ti.com/support/microcontrollers/hercules/f/312/t/347072

Q2: A strange behavior of event counters: I'd like to start one selected event counter at one time,

    _pmuInit_();
    _pmuEnableCountersGlobal_();
    _pmuResetCounters_();
    _pmuSetCountEvent_(pmuCOUNTER0, PMU_CYCLE_COUNT);
    _pmuStartCounters_(pmuCOUNTER0);
    cycles_start = _pmuGetEventCount_(pmuCOUNTER0);

    // RUN benchmark code...

    _pmuStopCounters_(pmuCOUNTER0);
    cycles_end = _pmuGetEventCount_(pmuCOUNTER0); // cycles_start and cycles_end are both 0!

Instead, if I start all 3 event counters at the same time, it works. Did I make a mistake in the code? I was totally lost.


Q3
:  In the tutorial, the event counter pmuCOUNTER0 is used to count the PMU cycles instead of PMU_CYCLE_COUNT. This method should have some benefits. For example, PMU_CYCLE_COUNT might go overflowed and reset to 0 automatically after some time?

From this perspective, pmuCOUNTER0 should better be reset each time when execution measurement starts. Correct?

    volatile uint32 cycles_start, cycles_end; 
    /* NOTE: reset all 3 event counters 0-2 */
    _pmuResetEventCounters_();
    /* select CPU cycles (Event 0x11) to be counted */
    _pmuSetCountEvent_(pmuCOUNTER0, PMU_CYCLE_COUNT);
    _pmuStartCounters_(pmuCOUNTER0);
    cycles_start = _pmuGetEventCount_(pmuCOUNTER0);

I'd like to reset only the specified event counter (pmuCOUNTER0) and keep other event counters going. Is this idea realizable in RM57? I couldn't find a function in "HL_sys_pmu.h" that resets specified event counters. Could I write an .asm file myself to do this task?

Do I have to configure the event counter once again after the reset? Must _pmuSetCountEvent_(pmuCOUNTER0, PMU_CYCLE_COUNT) be called directly after pmuResetEventCounters_(), in order to make the event counter pmuCOUNTER0 count the event "PMU cycles" after the reset?

Thanks in advance and best regards,

Honig