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.

AM263P4-Q1: About the function for measuring CPU load rate per core

Part Number: AM263P4-Q1

In the AM263Px MCU+ SDK 09.02.00 environment, we are measuring CPU load for a task running on Core1-0 with a 5 ms cycle using TaskP_loadGetTotalCpuLoad().
We are also measuring the task execution time using ClockP_getTimeUsec(). However, there is a significant discrepancy between the CPU load calculated from the task execution time and the CPU load reported by the API. What factors could cause this difference, and what should we check?

Below are examples of the measurements:

  • 5 ms cycle task CPU load: 5.677%
  • 5 ms cycle task execution time: 963.380 µsec

Since 963.380 / 5000 = 0.192676, the CPU load based on execution time should be about 19.2676%, but the measured CPU load is only 5.677%, which is much lower than expected.

  • Hi,

    The TaskP_loadGetTotalCpuLoad also uses ClockP_getTimeUsec internally to calculate the load.

    Are you only running 1 task while benchmarking it?

    What I think is happening here is that the task that you are benchmarking might be context switching in between and this additional time is also getting added into your ClockP_getTimeUsec() measurement, which could cause a mismatch.

    Can you try this with just 1 task, so that they is no context switching? In this case, it should match with TaskP_loadGetTotalCpuLoad

    Thanks and regards,

    Nikhil Dasan