<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>nRF52840 CPU Usage Accuracy and Explanation</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/100194/nrf52840-cpu-usage-accuracy-and-explanation</link><description>Hello, 
 
 I&amp;#39;m a beginner using the nRF52840 DK, sdk v16.0, and Keil on Windows. I&amp;#39;m currently working on the provided pwr_mgmt example. My first goal was to display the CPU Usage percentage as a float number, which I accomplished by editing the nrf_pwr_mgmt</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 09 Jun 2023 09:20:00 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/100194/nrf52840-cpu-usage-accuracy-and-explanation" /><item><title>RE: nRF52840 CPU Usage Accuracy and Explanation</title><link>https://devzone.nordicsemi.com/thread/430157?ContentTypeID=1</link><pubDate>Fri, 09 Jun 2023 09:20:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:638f1117-066c-4eb2-900e-ad2ac26fa2a7</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi Alan,&lt;br /&gt;&lt;br /&gt;Can you download SES v5.42a and build the example with that IDE and see if it results in the same?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Also, use SDK v17.1.0,&lt;/p&gt;
&lt;p&gt;This is what I used when I tested it last time and got 0% with the addition,&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 CPU Usage Accuracy and Explanation</title><link>https://devzone.nordicsemi.com/thread/430074?ContentTypeID=1</link><pubDate>Thu, 08 Jun 2023 20:33:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f800cd30-9904-4dd0-8d1c-6b5ce2db7193</guid><dc:creator>fwd159</dc:creator><description>&lt;p&gt;Hi Jared,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I deleted everything I had done previously and tried my algorithm with the original pwr_mgmt example code. Below is how I implemented it:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1686255597074v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;After compiling and flashing to the dev kit, I see the following on my terminal:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1686255678356v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;The only changes I made to this project were the addition function implementation and the function call in the main while loop. I&amp;#39;m confused now why the CPU Usage is even higher than before? I tried this code with the dev kit on SDK v16.0.0, but it&amp;#39;s my understanding that the results should be the same across SDK versions? Is it possible that you are optimizing for time when you&amp;#39;re compiling in the target options?&lt;/p&gt;
&lt;p&gt;For reference, I ran this pwr_mgmt project &lt;em&gt;without&lt;/em&gt; the addition function and I saw 0% CPU usage.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Alan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 CPU Usage Accuracy and Explanation</title><link>https://devzone.nordicsemi.com/thread/429233?ContentTypeID=1</link><pubDate>Mon, 05 Jun 2023 10:06:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f1e2f00e-5fe1-4b4b-94a8-b236e492e484</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi Alan,&lt;/p&gt;
&lt;p&gt;I tried adding the ME_addition() to the&amp;nbsp;&lt;span&gt;pwr_mgmt example and call it from the while loop just as you have done, and I&amp;#39;m not able to replicate the same on my development kit. My development kit shows 0% after adding this, have you done any other changes to your project? Are you able to replicate this on SDK v17.1.0?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1685959563943v1.png" alt=" " /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1685959587692v3.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 CPU Usage Accuracy and Explanation</title><link>https://devzone.nordicsemi.com/thread/429074?ContentTypeID=1</link><pubDate>Fri, 02 Jun 2023 19:52:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7d8ec2da-b929-47d8-95f3-35c374085c94</guid><dc:creator>fwd159</dc:creator><description>&lt;p&gt;Baseline CPU usage without line 30 is 0% (or ~0.3% with floating point representation).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 CPU Usage Accuracy and Explanation</title><link>https://devzone.nordicsemi.com/thread/428985?ContentTypeID=1</link><pubDate>Fri, 02 Jun 2023 11:39:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0bb0a291-3340-456b-871e-a96e2475f8eb</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;What do you measure if you don&amp;#39;t add the addition? What is the baseline CPU usage without adding line 30,&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 CPU Usage Accuracy and Explanation</title><link>https://devzone.nordicsemi.com/thread/428227?ContentTypeID=1</link><pubDate>Tue, 30 May 2023 14:34:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:04a4a446-d709-4b90-b819-3de086516be6</guid><dc:creator>fwd159</dc:creator><description>&lt;p&gt;I&amp;#39;m calling ME_addition() inside the main() function&amp;#39;s while loop (at line 30). I&amp;#39;ll include a code snippet below:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;int main(void)
{
    APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
    NRF_LOG_DEFAULT_BACKENDS_INIT();

    NRF_LOG_INFO(&amp;quot;Power Management example&amp;quot;);

    lfclk_config();

		uint32_t err_code = app_timer_init(); // drv_rtc.c:108 &amp;quot;RTC: initialized.&amp;quot;
    APP_ERROR_CHECK(err_code);

#if NRF_PWR_MGMT_CONFIG_USE_SCHEDULER
    APP_SCHED_INIT(APP_SCHED_MAX_EVENT_SIZE, APP_SCHED_QUEUE_SIZE);
#endif // NRF_PWR_MGMT_CONFIG_USE_SCHEDULER
	
    bsp_configuration();

		ret_code_t ret_code = nrf_pwr_mgmt_init(); // nrf_pwr_mgmt.c:326 &amp;quot;Init&amp;quot;
    APP_ERROR_CHECK(ret_code);

    while (true)
    {
			
#if NRF_PWR_MGMT_CONFIG_USE_SCHEDULER
        app_sched_execute();
#endif // NRF_PWR_MGMT_CONFIG_USE_SCHEDULER

			
		ME_addition();
			
        if (NRF_LOG_PROCESS() == false)
        {
            nrf_pwr_mgmt_run();
        }
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 CPU Usage Accuracy and Explanation</title><link>https://devzone.nordicsemi.com/thread/428223?ContentTypeID=1</link><pubDate>Tue, 30 May 2023 14:28:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e7d82698-6aa2-48fd-80b9-6b41a2c803fa</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;How are you calling&amp;nbsp;ME_addition(), in a loop?&lt;/p&gt;
&lt;p&gt;regards&lt;br /&gt;Jared&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 CPU Usage Accuracy and Explanation</title><link>https://devzone.nordicsemi.com/thread/428218?ContentTypeID=1</link><pubDate>Tue, 30 May 2023 14:25:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7d1be60e-2608-4d91-99cb-cd1c07b4db5b</guid><dc:creator>fwd159</dc:creator><description>&lt;p&gt;Hi Jared,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks for the timely reply. Without applying any changes to&amp;nbsp;&lt;span&gt;pwr_mgmt_cpu_usage_monitor_update() and running the basic addition function I implemented, the CPU usage is logged at 12%. Of course, without running my addition function, the CPU usage is at 0%.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Alan&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 CPU Usage Accuracy and Explanation</title><link>https://devzone.nordicsemi.com/thread/428214?ContentTypeID=1</link><pubDate>Tue, 30 May 2023 14:21:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f57b6bd5-45c8-4168-a68b-f76ec7e83cbe</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;What do you get if you don&amp;#39;t apply the changes to&amp;nbsp;&lt;span&gt;pwr_mgmt_cpu_usage_monitor_update()?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;regards&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Jared&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>