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.

MCU-PLUS-SDK-AM263PX: Profiling ISR with (ClockP, ticks)

Part Number: MCU-PLUS-SDK-AM263PX


My project has a high frequency interrupt which I need to profile.

I want to use a high frequency tick to do the profiling.

The API for clock

  AM263Px MCU+ SDK: APIs for Clock (ti.com)

... says that:

"ClockP_getTimeUsec shouldn't be called from an ISR with priority higher than that of Tick Interrupt"

Is the value of ClockP_getTimeUsec() safe if the return value is treated as a uint32_t?

(If not) Can you suggest an ISR-safe function for getting a high resolution tick?

Ideas:

  RTI

  ARM Cortex-R5 PMCR.D (Performance Monitor Control Register)

  • Hi Scott,

    Please refer to Benchmarking your Application in am26x academy or you could use the CCS In-built profiling-

    2. CCS base Profiling

    The profile clock can be used to count clock cycles

    Step 1: Enable the clock by going to menu Run -> Clock -> Enable

    The clock will be displayed in the CCS status bar at the bottom right

    Step 2: Double-click in the left selection margin of the editor beside line 67 in i2c_led_blink.c to set a breakpoint

    Step 3: Click the Resume button.

    The program will halt at the breakpoint and Clock will show the number of cycles to execute from the beginning of main to current breakpoint.

    Step 4: Double-click on the Clock icon to reset the count to 0

    Step 5: Click the Resume button again.

    The Clock will show the number of cycles to execute from the previous breakpoint to the current breakpoint (~25M cycles between each LED blink)

    Step 6: Click the Resume button several times and note that the clock cycles increment by about the same number each time

    Step 7: Disable the clock

    Diable the clock by going to menu Run -> Clock -> Disable

    Step 8: Remove the breakpoint

    Remove the breakpoint by selecting the breakpoint in the Breakpoints view and clicking the Remove button.

    Please let me know if any of these ways would suffice for your Profiling purpose.

    Regards,
    Akshit

  • Hi Akshit,

    Thanks for the information. This is very helpful. I will be using this for profiling code as I develop. 

    However, I also am looking for a programmatic way test for 'in-filed', and regression test.

    I want to:

    • call a high resolution (microsecond preferable) 'get start tick'.
    • execute the code being profiled.
    • call a high resolution (microsecond preferable) 'get end tick'.
    • compute statistics on the difference in  'end tick' and 'start tick'.

    This allows for finding inadvertent issues affecting timing over the life-cycle of the project.

    I want this 'get tick' call to be ISR safe so it can used this scheme to profile ISRs.

    Regards,

    Tollman

  • I see,

    The Cycle Counter API provided in the SDK can be used for this purpose. Under the hood this API either uses the Performance Management Unit (PMU) inside the R5F core

    Please go through the following Academy chapter, which provides all information on how to use the Cycle Counter API's to benchmark your application and get the time in microseconds :-

    https://dev.ti.com/tirex/explore/node?node=A__AQqj77FsezRfjwqo2b.arQ__AM26X-ACADEMY__t0CaxbG__LATEST

    Let me know if this is what you were looking for!

    Regards,
    Akshit