<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Model-Based Design Toolbox (MBDT)中的主题 Re: MBDT blocks for measuring Idle Time or ProcessorLoad</title>
    <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/MBDT-blocks-for-measuring-Idle-Time-or-ProcessorLoad/m-p/1081223#M4719</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&amp;nbsp;&lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/chrisc@rmlgroup.com"&gt;chrisc@rmlgroup.com&lt;/A&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We do not have a block that can tell you the CPU load, but I can think of ways in which you could achieve that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lets look at how an application generated by our toolbox looks like (main parts in regards with execution time):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_2.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/113700i94127A9489A8DFA1/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_2.png" alt="pastedImage_2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We have the following:&lt;/P&gt;&lt;UL style="margin-top: 0in;"&gt;&lt;LI style="margin-left: .25in;"&gt;Step – a function called periodically, with a frequency controlled by the Discrete Step value set in the model&lt;/LI&gt;&lt;LI style="margin-left: .25in;"&gt;Interrupts – asynchronous events that can be further grouped into 2 categories:&lt;UL style="margin-top: 0in;"&gt;&lt;LI style="margin-left: .25in;"&gt;Events that occur at a known period – e.g. a LPIT block that is used to trigger the Fast loop system for motor control applications – the important part is that you control the frequency at which this event occurs&lt;/LI&gt;&lt;LI style="margin-left: .25in;"&gt;Events that have an unknown period – e.g. receiving a message via UART/SPI/I2C/etc. – this is something that you have no control over, it can happen any time&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI style="margin-left: .25in;"&gt;Initialization – this is an important part of the application, but for CPU load it is of no importance&lt;/LI&gt;&lt;LI style="margin-left: .25in;"&gt;IDLE – this is the time period in which the Step function finished execution and awaits to be re-triggered and you have no ISR to execute (no such events were generated)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looking at these, I see 2 options:&lt;/P&gt;&lt;UL style="margin-top: 0in;"&gt;&lt;LI style="margin-left: .25in;"&gt;Either calculate the IDLE time between 2 events that trigger the Step function to be executed&lt;/LI&gt;&lt;LI style="margin-left: .25in;"&gt;Either calculate the time you spend in Step + time spent in ISRs, all before a 2&lt;SUP&gt;nd&lt;/SUP&gt; start of the Step function&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the 1&lt;SUP&gt;st&lt;/SUP&gt; option, it’s harder to implement just in Simulink, so lets explore the 2&lt;SUP&gt;nd&lt;/SUP&gt; option.&lt;/P&gt;&lt;P&gt;To get the CPU Load, we’ll calculate it like this:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;CPU Load = Step Load + ISR Load&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;For this, we’ll start with the Step time – you can use the profiler block, put it into the top model and you’ll get the total execution time of the Step function. This is easy enough:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;Step load = step execution time / discrete step value&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Now onto the ISRs – this is where it gets a bit more complicated. I have grouped them into 2 categories (see above) for the following reason: even if we can calculate the execution time using the same Profiler blocks, we do not know the frequency of all events – for those controlled by the LPIT blocks, we can do the same as for the Step; but for the other, we can’t include them into our calculation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I’m thinking that these kind of events tend to have small ISRs, so if we’re not aiming for perfect accuracy for the CPU load calculation, it should be close enough without taking them into account. &amp;nbsp;If we do this, we end up with the following:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;ISRn Load = ISRn execution time / ISRn period&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;To get ISR total Load we just sum every ISRn Load.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically you end up having to put 1 profiler block in the main loop (top model) + 1 profiler block per ISR. At the end, you can get these values in FreeMASTER and use them to get an approximation for CPU Load.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let’s take an example:&lt;/P&gt;&lt;P&gt;We have set the following:&lt;/P&gt;&lt;P style="text-indent: .5in;"&gt;discrete time: 1s (so step will be triggered every 1s)&lt;/P&gt;&lt;P style="text-indent: .5in;"&gt;step execution time: 0.2s (code for step takes 200ms to execute)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="text-indent: .5in;"&gt;ISR1 freq: 0.2s (we trigger a subsystem using LPIT block every 200ms)&lt;/P&gt;&lt;P style="text-indent: .5in;"&gt;ISR execution time: 0.1s (that subsystem takes 100ms to finish it’s execution)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="text-indent: .5in;"&gt;Note: in this example ISR1 has higher priority than step&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;Time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Function starting execution&lt;/P&gt;&lt;P&gt;0.0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ISR1&lt;/P&gt;&lt;P&gt;0.1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Step&lt;/P&gt;&lt;P&gt;0.2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ISR1&lt;/P&gt;&lt;P&gt;0.3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Step&lt;/P&gt;&lt;P&gt;0.4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ISR1&lt;/P&gt;&lt;P&gt;0.5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IDLE&lt;/P&gt;&lt;P&gt;0.6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ISR1&lt;/P&gt;&lt;P&gt;0.7&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IDLE&lt;/P&gt;&lt;P&gt;0.8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ISR1&lt;/P&gt;&lt;P&gt;0.9&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IDLE&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;1.0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;– the whole process starts repeating&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here we can see the following:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;ISR1 execution time&amp;nbsp; = 5 x 0.1s = 0.5s&lt;/P&gt;&lt;P&gt;step execution time&amp;nbsp; &amp;nbsp;= 1 x 0.2s = 0.2s&lt;/P&gt;&lt;P&gt;idle&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;= 3 x 0.1s = 0.3s&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;So CPU load is 70%. Now lets test out the formula I proposed earlier:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;Step load = 0.2 / 0.1 = 0.2 = 20%&lt;/P&gt;&lt;P&gt;ISR load = ISR1 load = 0.1 / 0.2 = 0.5 = 50%&lt;/P&gt;&lt;P&gt;CPU Load = Step load + ISR load = 20% + 50% = 70%&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Note: the profiler block returns a value in ticks – those are ticks at a &lt;STRONG style="color: #ff0000; text-decoration: line-through; "&gt;40MHz&lt;/STRONG&gt; &lt;SPAN style="color: #008000;"&gt;&lt;STRONG&gt;20MHz (edited)&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;frequency – you can use this information to convert from ticks to execution time (both for the main loop and other ISRs).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note2: you must select a different index for each profiler block (option available in the mask) – otherwise the values will just overwrite one another.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope I made things clear about how you could get the CPU load with our toolbox and FreeMASTER.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Razvan.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 23 Jun 2020 16:35:49 GMT</pubDate>
    <dc:creator>constantinrazva</dc:creator>
    <dc:date>2020-06-23T16:35:49Z</dc:date>
    <item>
      <title>MBDT blocks for measuring Idle Time or ProcessorLoad</title>
      <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/MBDT-blocks-for-measuring-Idle-Time-or-ProcessorLoad/m-p/1081222#M4718</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;Is there any documentation page that explains how to place a block in MBDT that measures Idle Time or Processor Load?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;I can see this article(s) &lt;/SPAN&gt;&lt;A href="https://protect-eu.mimecast.com/s/gYwOCz74qI8XZQFXiN6a?domain=eur01.safelinks.protection.outlook.com"&gt;https://community.nxp.com/thread/471486&lt;/A&gt; ; &lt;A href="https://protect-eu.mimecast.com/s/oUOwCBPX1IPxrpSjCfft?domain=eur01.safelinks.protection.outlook.com"&gt;https://community.nxp.com/thread/328304&lt;/A&gt; ; &lt;A href="https://protect-eu.mimecast.com/s/ANOOCE0XKc1w2VTQ__7M?domain=eur01.safelinks.protection.outlook.com"&gt;https://community.nxp.com/thread/51447&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;but that doesn’t give many details for a Simulink implementation. I looked for an Idle Counter block but have not seen one so far. However I can see a Profiler block so I am thinking that I could use that if all of my code (for the moment) runs in a single task.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; color: #1f497d;"&gt;I'm aiming to&amp;nbsp;check how hard I’m pushing the processor with what I’ve implemented so far, and how much difference I can make by slowing down the task.&amp;nbsp; :-)&amp;nbsp; Generally I try to stay within 75% ProcLoad.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2020 16:13:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/MBDT-blocks-for-measuring-Idle-Time-or-ProcessorLoad/m-p/1081222#M4718</guid>
      <dc:creator>chrisc1</dc:creator>
      <dc:date>2020-06-23T16:13:28Z</dc:date>
    </item>
    <item>
      <title>Re: MBDT blocks for measuring Idle Time or ProcessorLoad</title>
      <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/MBDT-blocks-for-measuring-Idle-Time-or-ProcessorLoad/m-p/1081223#M4719</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&amp;nbsp;&lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/chrisc@rmlgroup.com"&gt;chrisc@rmlgroup.com&lt;/A&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We do not have a block that can tell you the CPU load, but I can think of ways in which you could achieve that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lets look at how an application generated by our toolbox looks like (main parts in regards with execution time):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_2.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/113700i94127A9489A8DFA1/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_2.png" alt="pastedImage_2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We have the following:&lt;/P&gt;&lt;UL style="margin-top: 0in;"&gt;&lt;LI style="margin-left: .25in;"&gt;Step – a function called periodically, with a frequency controlled by the Discrete Step value set in the model&lt;/LI&gt;&lt;LI style="margin-left: .25in;"&gt;Interrupts – asynchronous events that can be further grouped into 2 categories:&lt;UL style="margin-top: 0in;"&gt;&lt;LI style="margin-left: .25in;"&gt;Events that occur at a known period – e.g. a LPIT block that is used to trigger the Fast loop system for motor control applications – the important part is that you control the frequency at which this event occurs&lt;/LI&gt;&lt;LI style="margin-left: .25in;"&gt;Events that have an unknown period – e.g. receiving a message via UART/SPI/I2C/etc. – this is something that you have no control over, it can happen any time&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI style="margin-left: .25in;"&gt;Initialization – this is an important part of the application, but for CPU load it is of no importance&lt;/LI&gt;&lt;LI style="margin-left: .25in;"&gt;IDLE – this is the time period in which the Step function finished execution and awaits to be re-triggered and you have no ISR to execute (no such events were generated)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looking at these, I see 2 options:&lt;/P&gt;&lt;UL style="margin-top: 0in;"&gt;&lt;LI style="margin-left: .25in;"&gt;Either calculate the IDLE time between 2 events that trigger the Step function to be executed&lt;/LI&gt;&lt;LI style="margin-left: .25in;"&gt;Either calculate the time you spend in Step + time spent in ISRs, all before a 2&lt;SUP&gt;nd&lt;/SUP&gt; start of the Step function&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the 1&lt;SUP&gt;st&lt;/SUP&gt; option, it’s harder to implement just in Simulink, so lets explore the 2&lt;SUP&gt;nd&lt;/SUP&gt; option.&lt;/P&gt;&lt;P&gt;To get the CPU Load, we’ll calculate it like this:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;CPU Load = Step Load + ISR Load&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;For this, we’ll start with the Step time – you can use the profiler block, put it into the top model and you’ll get the total execution time of the Step function. This is easy enough:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;Step load = step execution time / discrete step value&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Now onto the ISRs – this is where it gets a bit more complicated. I have grouped them into 2 categories (see above) for the following reason: even if we can calculate the execution time using the same Profiler blocks, we do not know the frequency of all events – for those controlled by the LPIT blocks, we can do the same as for the Step; but for the other, we can’t include them into our calculation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I’m thinking that these kind of events tend to have small ISRs, so if we’re not aiming for perfect accuracy for the CPU load calculation, it should be close enough without taking them into account. &amp;nbsp;If we do this, we end up with the following:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;ISRn Load = ISRn execution time / ISRn period&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;To get ISR total Load we just sum every ISRn Load.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically you end up having to put 1 profiler block in the main loop (top model) + 1 profiler block per ISR. At the end, you can get these values in FreeMASTER and use them to get an approximation for CPU Load.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let’s take an example:&lt;/P&gt;&lt;P&gt;We have set the following:&lt;/P&gt;&lt;P style="text-indent: .5in;"&gt;discrete time: 1s (so step will be triggered every 1s)&lt;/P&gt;&lt;P style="text-indent: .5in;"&gt;step execution time: 0.2s (code for step takes 200ms to execute)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="text-indent: .5in;"&gt;ISR1 freq: 0.2s (we trigger a subsystem using LPIT block every 200ms)&lt;/P&gt;&lt;P style="text-indent: .5in;"&gt;ISR execution time: 0.1s (that subsystem takes 100ms to finish it’s execution)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="text-indent: .5in;"&gt;Note: in this example ISR1 has higher priority than step&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;Time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Function starting execution&lt;/P&gt;&lt;P&gt;0.0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ISR1&lt;/P&gt;&lt;P&gt;0.1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Step&lt;/P&gt;&lt;P&gt;0.2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ISR1&lt;/P&gt;&lt;P&gt;0.3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Step&lt;/P&gt;&lt;P&gt;0.4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ISR1&lt;/P&gt;&lt;P&gt;0.5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IDLE&lt;/P&gt;&lt;P&gt;0.6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ISR1&lt;/P&gt;&lt;P&gt;0.7&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IDLE&lt;/P&gt;&lt;P&gt;0.8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ISR1&lt;/P&gt;&lt;P&gt;0.9&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IDLE&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;1.0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;– the whole process starts repeating&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here we can see the following:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;ISR1 execution time&amp;nbsp; = 5 x 0.1s = 0.5s&lt;/P&gt;&lt;P&gt;step execution time&amp;nbsp; &amp;nbsp;= 1 x 0.2s = 0.2s&lt;/P&gt;&lt;P&gt;idle&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;= 3 x 0.1s = 0.3s&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;So CPU load is 70%. Now lets test out the formula I proposed earlier:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;Step load = 0.2 / 0.1 = 0.2 = 20%&lt;/P&gt;&lt;P&gt;ISR load = ISR1 load = 0.1 / 0.2 = 0.5 = 50%&lt;/P&gt;&lt;P&gt;CPU Load = Step load + ISR load = 20% + 50% = 70%&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Note: the profiler block returns a value in ticks – those are ticks at a &lt;STRONG style="color: #ff0000; text-decoration: line-through; "&gt;40MHz&lt;/STRONG&gt; &lt;SPAN style="color: #008000;"&gt;&lt;STRONG&gt;20MHz (edited)&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;frequency – you can use this information to convert from ticks to execution time (both for the main loop and other ISRs).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note2: you must select a different index for each profiler block (option available in the mask) – otherwise the values will just overwrite one another.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope I made things clear about how you could get the CPU load with our toolbox and FreeMASTER.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Razvan.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2020 16:35:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/MBDT-blocks-for-measuring-Idle-Time-or-ProcessorLoad/m-p/1081223#M4719</guid>
      <dc:creator>constantinrazva</dc:creator>
      <dc:date>2020-06-23T16:35:49Z</dc:date>
    </item>
    <item>
      <title>Re: MBDT blocks for measuring Idle Time or ProcessorLoad</title>
      <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/MBDT-blocks-for-measuring-Idle-Time-or-ProcessorLoad/m-p/1081224#M4720</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you&amp;nbsp;&lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/constantinrazvan.chivu"&gt;constantinrazvan.chivu&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In a previous post&amp;nbsp;&lt;A href="https://community.nxp.com/thread/515047"&gt;How do I use the Profiler Function correctly?&lt;/A&gt;&amp;nbsp; you mention a ratio of SPLL/4.&lt;/P&gt;&lt;P&gt;If this is the case, then the value I see displayed in FreeMaster of 135690 should be used in such calculation (I think):&lt;/P&gt;&lt;P&gt;135690 ticks / 80 MHz / 4 = 424 microseconds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My whole model is running at 0.005 seconds, so I'm not sure if this would indicate a very approximate processor load of 8.5% or if I need to carry out a further calculation to obtain that value. As mentioned above, at the moment I only really wish to check from one build to another that I don't add anything that has a big slow-down kind of impact.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Much appreciated the help, thank you.&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jun 2020 09:15:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/MBDT-blocks-for-measuring-Idle-Time-or-ProcessorLoad/m-p/1081224#M4720</guid>
      <dc:creator>chrisc1</dc:creator>
      <dc:date>2020-06-25T09:15:11Z</dc:date>
    </item>
    <item>
      <title>Re: MBDT blocks for measuring Idle Time or ProcessorLoad</title>
      <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/MBDT-blocks-for-measuring-Idle-Time-or-ProcessorLoad/m-p/1081225#M4721</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&amp;nbsp;&lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/chrisc@rmlgroup.com"&gt;chrisc@rmlgroup.com&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On that thread you linked I was right about the frequency of the profiler – it is indeed &lt;STRONG&gt;20MHz&lt;/STRONG&gt;, as it is SPLL divided by 4, but I have made an error regarding to the calculations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you have 135690 profiler ticks (clock frequency being 20MHz), you’ll get 135690 / 20000000 = 0.00678s = 6.78ms.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will have to take a look at where in the model you are putting the profiler block, as it can’t take 6ms to execute a task that is called upon every 5ms – either the application is not running correctly, either the number is calculating something else – but I tend to think that you are using the block correctly, and it just can’t fit into the 5ms window you want to use.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will correct the other thread (which you linked) – I talked so much about core ticks vs profiler clock ticks and how to convert from one into another that I ended up confusing myself on how you should calculate the absolute execution time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To make it clear, you should get the number returned by the profiler block (that has frequency of 20MHz) and divide it to this exact frequency to get the result expressed into seconds.&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;Execution time = profiler ticks / 20 000 000&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;You can also convert from profiler ticks to core ticks by multiplying this number by 4.&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;Core ticks = profiler ticks x 4&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;The period will remain the same, but now you’ll have the following:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;Execution time = (profiler ticks x 4) &amp;nbsp;/ &amp;nbsp;(20MHz x 4)&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;As you can see, as both the nominator and the denominator have been multiplied by the same constant, if you simplify this, you’ll end up with the first formula.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this clears things up a bit – just to be sure, you can send me the model or explain where you put the profiler block in regards to the model, just to make sure the number we are seeing is representing what we think it is. You could also send a picture where you just take out other blocks that you don’t want to share – I’m interested only in how you measure the time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Razvan.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Jun 2020 08:37:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/MBDT-blocks-for-measuring-Idle-Time-or-ProcessorLoad/m-p/1081225#M4721</guid>
      <dc:creator>constantinrazva</dc:creator>
      <dc:date>2020-06-29T08:37:25Z</dc:date>
    </item>
  </channel>
</rss>

