How to calculate CPU load analyis for the MM9Z1_638 controller

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to calculate CPU load analyis for the MM9Z1_638 controller

666 Views
krishnakarthik
Contributor I

Hi,

 

I am working in Battery management project and there is a request to find out the CPU utilization by individual tasks and also CPU load analysis. In the present scenario RTI interrupt is configured at 1ms for OS scheduling. As task run time will be less than 10 or 100 micro seconds, so i thought to use the API (Autonomous periodic interrupt) at 1 micro second to find the task timing on CPU which is NOT a right method. So please let me know, if we can monitor any controller registers or please suggest any methods to find the CPU load and individual tasks run time

Labels (1)
0 Kudos
3 Replies

511 Views
krishnakarthik
Contributor I

Hello Radek,

Thanks for info. But my use case is different, where i have to find CPU utilization by the individual tasks. Say i have 4 tasks which are called at 10ms, 100ms, 200ms, 500ms frequency. So i have to calculate CPU utilization by each task also i have to find CPU utilization by the ISR also. Please let me know your thoughts (or ideas ) and also details of  timers (or counters ) in the MM9Z1_638 controller to be used to accomplish the same

Thanks in advance

0 Kudos

510 Views
RadekS
NXP Employee
NXP Employee

Hi Krishna,

Thank you for clarification.

Ok, you don’t need to know how much you CPU power remains, but you want to inspect the whole task management. You probably need some Task Awareness. Something like https://mcuoneclipse.com/2016/07/06/freertos-kernel-awareness-for-eclipse-from-nxp/

or

https://mcuoneclipse.com/2016/06/13/adding-freertos-thread-awareness-to-gdb-and-eclipse/

or

https://mcuoneclipse.com/2013/08/04/diy-free-toolchain-for-kinetis-part-5-freertos-eclipse-kernel-aw...

,but at CW and S12Z.

Did you already tray any of similar tools? I suppose that there must be some relative wide area of available tools, but I am not sure with S12Z toolchain compatibility.

I suppose that some solution which will periodically read RTOS kernel data and stack trough BDM interface and analyze it on PC side is the most logical and least intrusive method for that debugging.

I hope it helps you.

Have a great day,
Radek

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

511 Views
RadekS
NXP Employee
NXP Employee

Hi Krishna,

I am afraid that the “the API (Autonomous periodic interrupt) at 1 micro second” is not the right idea.

  1. The API clock is much slower. The default ACLK frequency is 20kHz (or 10kHz – it depends on ACLK definition). So, you cannot interrupt CPU every 1us.
  2. The every jump/return to/from interrupt needs some time. For simplicity, we could calculate with 8-10 bus cycles per every enter/leave. So even for highest 50MHz bus clock, you need at least 0.32us just for handling interrupt routine (stack/unstack,…)

For the CPU load analysis, we typically use the idle task with the lowest priority between tasks.

This task does nothing (just simple endless loop) or simply counts a counter.

You could periodically read this counter and see how much it counts per unit time. If the difference from the last check will be 0, the CPU load is 100%. The value for 0% CPU load depends on idle task code, counter size and length of the periodic check. You could simply measure it when you block all your task except idle task and task who check the counter value.

I hope it helps you.

Have a great day,
Radek

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos