<?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>FreeRTOS and app_scheduler combined</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/65401/freertos-and-app_scheduler-combined</link><description>Hi all, 
 For a project I need to use a private library which uses the app_scheduler to queue events triggered from a second MCU. I am using FreeRTOS on the nRF and I am unsure how to make the app_scheduler work together with FreeRTOS. The supplier of</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 26 Sep 2022 15:35:26 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/65401/freertos-and-app_scheduler-combined" /><item><title>RE: FreeRTOS and app_scheduler combined</title><link>https://devzone.nordicsemi.com/thread/387979?ContentTypeID=1</link><pubDate>Mon, 26 Sep 2022 15:35:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f23231b0-c9f4-4650-b246-3f46de6e1503</guid><dc:creator>Lora</dc:creator><description>&lt;p&gt;&lt;span style="font-family:&amp;#39;times new roman&amp;#39;, times;"&gt;Hi&amp;nbsp;&lt;a class="internal-link view-user-profile" href="https://devzone.nordicsemi.com/members/aryan"&gt;Susheel Nuguru&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;a class="internal-link view-user-profile" href="https://devzone.nordicsemi.com/members/jur"&gt;Jur&lt;/a&gt;,&lt;/span&gt;&lt;/p&gt;
&lt;pre id="tw-target-text" class="tw-data-text tw-text-large tw-ta" dir="ltr" data-placeholder="Traduction"&gt;&lt;span class="Y2IQFc" style="font-family:&amp;#39;times new roman&amp;#39;, times;" lang="en"&gt;Could you share an example using app_scheduler.h library and freeRTOS please .

I have a problem and I&amp;#39;m stuck on this part.&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;times new roman&amp;#39;, times;"&gt;Thank you for your help .&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FreeRTOS and app_scheduler combined</title><link>https://devzone.nordicsemi.com/thread/275880?ContentTypeID=1</link><pubDate>Tue, 20 Oct 2020 11:40:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b6ba892e-df8c-4983-aeeb-2efda787096c</guid><dc:creator>Jur</dc:creator><description>&lt;p&gt;I would just like to add something for developers that may come across this thread who need to do the same thing:&lt;br /&gt;&lt;br /&gt;When using the idle hook to call app_sched_execute() whatever is queued for the Scheduler will (obviously) be executed within the idle task. I got stack overflows and undefined behavior as a result of the stack size of the idle task being too small for the scheduled events. When you run into the same problem you can increase configMINIMAL_STACK_SIZE within FreeRTOSConfig.h. This will also increase the stack size of the idle task &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FreeRTOS and app_scheduler combined</title><link>https://devzone.nordicsemi.com/thread/274619?ContentTypeID=1</link><pubDate>Tue, 13 Oct 2020 12:11:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:de4e5780-89de-4cb9-8e3b-97077bdd5ba2</guid><dc:creator>Jur</dc:creator><description>&lt;p&gt;No worries, I hope you&amp;#39;re okay! Thanks a lot for helping me, appreciated! It is all clear now :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FreeRTOS and app_scheduler combined</title><link>https://devzone.nordicsemi.com/thread/274188?ContentTypeID=1</link><pubDate>Mon, 12 Oct 2020 07:01:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:636d3d41-49f8-4842-906e-8133c92137c2</guid><dc:creator>Susheel Nuguru</dc:creator><description>[quote user="Jur"]This works great but it is not the cleanest solution. So do I understand correctly that I can use tickless idle and idle hook together when not making the chip sleep in the idle hook?[/quote]
&lt;p&gt;&amp;nbsp;Firstly sorry for the late reply. I was sick and just returned to work today.&lt;/p&gt;
&lt;p&gt;Yes your understanding is correct. The idea of enabling tickless idle is to give the RTOS control on sleep states of the chip. So when enabling tickless idle, the sleep state should only be at one place for the RTOS to properly have control on the ticks and later adjusting the missing ticks.&lt;/p&gt;
&lt;p&gt;Using idle hook and tickless idle is completely ok as long as you do not use any sleep states in the idle hook.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="Jur"]So do I understand correctly that I can use tickless idle and idle hook together when not making the chip sleep in the idle hook? In that case I can use tickless idle for sleeping and the idle hook for just calling app_sched_execute(). [/quote]
&lt;p&gt;&amp;nbsp;correct.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FreeRTOS and app_scheduler combined</title><link>https://devzone.nordicsemi.com/thread/273429?ContentTypeID=1</link><pubDate>Wed, 07 Oct 2020 09:56:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:230aaa7e-89a9-40b9-b1c6-a6875257d3f2</guid><dc:creator>Jur</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/aryan"&gt;Susheel Nuguru&lt;/a&gt;&amp;nbsp;Thanks for your reply! I am sorry I should have explained! I was making the chip go to sleep. So in the idle hook, I would call&amp;nbsp;app_sched_execute() and after that make the chip go to sleep using sd_app_evt_wait(). So I was actually doing the same as the developer in the thread I linked.&lt;/p&gt;
&lt;p&gt;Meanwhile I did the following:&lt;br /&gt;I added a call to app_sched_execute() to the top of the vPortSuppressTicksAndSleep() function defined in port_cmsis_systick.c .&lt;/p&gt;
&lt;p&gt;This works great but it is not the cleanest solution. So do I understand correctly that I can use tickless idle and idle hook together when not making the chip sleep in the idle hook? In that case I can use tickless idle for sleeping and the idle hook for just calling app_sched_execute(). Will this first execute the idle hook and after completing this go into tickless idle? Or is there no way to guarantee that the hook will be executed before going into tickless idle?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FreeRTOS and app_scheduler combined</title><link>https://devzone.nordicsemi.com/thread/273359?ContentTypeID=1</link><pubDate>Wed, 07 Oct 2020 06:59:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7258f2c2-c893-49b2-ad3a-b1660a482bc6</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Jur,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The developer in the thread link you provided was using sleep function both in idle_hook and also enabled the tickless idle (tickless idle one of the main task is to handle sleep). My recommendation to the customer was not to use sleep in both of these (idle_hook and tickless idle) as it is not necessary and also incorrect.&lt;/p&gt;
&lt;p&gt;In your case, i assume you are only using app_scheduler in idle_hook and not making the chip go into any sleep states? If this is the case, then using both idle_hook and tickless idle should work very well together in my opinion.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FreeRTOS and app_scheduler combined</title><link>https://devzone.nordicsemi.com/thread/272667?ContentTypeID=1</link><pubDate>Fri, 02 Oct 2020 08:18:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b8a5cfb7-0b12-4974-a007-cd67e5e121ad</guid><dc:creator>Jur</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/aryan"&gt;Susheel Nuguru&lt;/a&gt; This worked out great, but now I would like to use the tickless idle to save some more power A &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/17392/what-should-i-do-in-freertos-function-vapplicationidlehook-to-save-power"&gt;verified answer&lt;/a&gt; made by you explains how USE_TICKLESS_IDLE and USE_IDLE_HOOK should not be used at the same time.&lt;br /&gt;&lt;br /&gt;What do you think about the following approach:&lt;br /&gt;&lt;br /&gt;Adding the call to app_sched_execute() to the top of the vPortSuppressTicksAndSleep() function defined in port_cmsis_systick.c .&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FreeRTOS and app_scheduler combined</title><link>https://devzone.nordicsemi.com/thread/267245?ContentTypeID=1</link><pubDate>Mon, 31 Aug 2020 12:44:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e7dfc8a9-9d01-43d8-88fe-e4c091ee7b5f</guid><dc:creator>Jur</dc:creator><description>&lt;p&gt;Great answer! Thanks a lot!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FreeRTOS and app_scheduler combined</title><link>https://devzone.nordicsemi.com/thread/267238?ContentTypeID=1</link><pubDate>Mon, 31 Aug 2020 12:28:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cb0d64da-1fec-4433-988b-15d82b0da8da</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi Jur,&lt;/p&gt;
[quote user=""]After reading the app_scheduler documentation I figured I need to initialise it first. I do this before calling the vTaskStartScheduler() function. But I read I also need to call app_sched_execute() in my main loop to check for items in the event queue and process them.&amp;nbsp;[/quote]
&lt;p&gt;You can enable the application idle hook in FreeRTOSConfig.h and call the&amp;nbsp;&amp;nbsp;&lt;span&gt;app_sched_execute in it so that it gets called from the idle_task.. It suits very well in your case. I do not see any conflicts in using app_scheduler when executing the queued contexts from the application idle hook.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>