<?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>How to create two task with different task priority?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/31164/how-to-create-two-task-with-different-task-priority</link><description>SDK version: 14.2.0 
 I use &amp;quot;ble_app_hrs_freertos&amp;quot; as code base and modify it to create a &amp;quot;ble_app_template_freertos&amp;quot; project. 
 &amp;quot; softdevice_task &amp;quot; is already in this project (uxPriority = 2 ). 
 I can use &amp;quot; xTaskCreate &amp;quot; to create a new task &amp;quot; task1</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 24 Aug 2018 21:35:00 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/31164/how-to-create-two-task-with-different-task-priority" /><item><title>RE: How to create two task with different task priority?</title><link>https://devzone.nordicsemi.com/thread/145734?ContentTypeID=1</link><pubDate>Fri, 24 Aug 2018 21:35:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b112e4b2-5329-495b-b31d-9cc9d980f606</guid><dc:creator>donald@l2finc.com</dc:creator><description>&lt;p&gt;Hello Aryan &amp;amp; Cooper,&lt;/p&gt;
&lt;p&gt;I am new to Embedded Studio &amp;amp; Nordic; I have&amp;nbsp;tried different way to create two another thread with this project. But system crashed every time.&lt;/p&gt;
&lt;p&gt;If I can comment out:&lt;/p&gt;
&lt;p&gt;// nrf_sdh_freertos_init(advertising_start, &amp;amp;erase_bonds);,&lt;/p&gt;
&lt;p&gt;and keep task1_thread, but comment out&amp;nbsp;task2_thread; then task1_thread is running correct.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;I changed configMAX_PRIORITIES 6; did not see difference.&amp;nbsp;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;I changed configTOTAL_HEAP_SIZE to 8192; did not see difference&lt;/p&gt;
&lt;p&gt;I am using:&lt;/p&gt;
&lt;p&gt;&lt;span&gt;SEGGER Embedded Studio for ARM&lt;br /&gt;Release 3.40&amp;nbsp;&amp;nbsp;Build 2018052200.36079&lt;br /&gt;Windows x64&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;nRF52840 DK&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;C:\Nordic_Semi\nRF5_SDK_15.0.0_a53641a\examples\ble_peripheral\ble_app_hrs_freertos\pca10056\s140\ses as base project.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The test that I created:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt; if (pdPASS != xTaskCreate(task1_thread, &amp;quot;TASK1&amp;quot;, 128, NULL, 3, &amp;amp;m_task1_thread))&lt;br /&gt; {&lt;br /&gt; APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);&lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt; NRF_LOG_INFO(&amp;quot;SPT FreeRTOS created.&amp;quot;);&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Again, I must comment out:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;// nrf_sdh_freertos_init(advertising_start, &amp;amp;erase_bonds);,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;to make it work.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Please help if you can, I am really appreciated.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Donald&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to create two task with different task priority?</title><link>https://devzone.nordicsemi.com/thread/124490?ContentTypeID=1</link><pubDate>Thu, 15 Mar 2018 07:21:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a0dbe920-7291-4c45-94ea-b8141442d1a2</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;my bad, I should have seen this.&lt;/p&gt;
&lt;p&gt;Look at &lt;a href="https://www.freertos.org/RTOS-task-priority.html"&gt;this&lt;/a&gt; link. You cannot use priorities for task which is more than (&lt;strong&gt;configMAX_PRIORITIES - 1).&amp;nbsp;&lt;/strong&gt;Since you were trying to use the numbers more than that scheduler was working in a unpredictable way. Next SDK we have updated the FreeRTOS kernel to 10.0.0 where i think you get an assert if you use illegal priority numbers to task, helping us to catch the error faster.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to create two task with different task priority?</title><link>https://devzone.nordicsemi.com/thread/124255?ContentTypeID=1</link><pubDate>Wed, 14 Mar 2018 02:49:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8591446f-3106-4630-9311-b9ceec1a5aea</guid><dc:creator>Cooper</dc:creator><description>&lt;p&gt;Hi Aryan&lt;/p&gt;
&lt;p&gt;I modify the&amp;nbsp;&lt;span&gt;&lt;strong&gt;configTOTAL_HEAP_SIZE&lt;/strong&gt; from 4096 to 8192, but still not working.&lt;br /&gt;But when I modify&amp;nbsp;&lt;strong&gt;configMAX_PRIORITIES&lt;/strong&gt; from 3 to 4 it works!! And I can change any &lt;strong&gt;uxPriority&lt;/strong&gt; value what I want.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Did you know why?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to create two task with different task priority?</title><link>https://devzone.nordicsemi.com/thread/124191?ContentTypeID=1</link><pubDate>Tue, 13 Mar 2018 14:22:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cabaf201-3f1c-4c8e-870c-e924877b4e0d</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I disabled the logs and it worked just fine. for logs , i think you need to increase&amp;nbsp;the heap size.&amp;nbsp; configTOTAL_HEAP_SIZE&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to create two task with different task priority?</title><link>https://devzone.nordicsemi.com/thread/124054?ContentTypeID=1</link><pubDate>Tue, 13 Mar 2018 03:48:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:91ea6a6f-4939-418a-b582-2c0ac15bdc90</guid><dc:creator>Cooper</dc:creator><description>&lt;p&gt;Hi Aryan&lt;/p&gt;
&lt;p&gt;Have you tested my code?&lt;br /&gt;Got the same result or work normally?&lt;/p&gt;
&lt;p&gt;I try to found the issue, but still not working.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to create two task with different task priority?</title><link>https://devzone.nordicsemi.com/thread/123548?ContentTypeID=1</link><pubDate>Fri, 09 Mar 2018 07:36:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:18c6ab7d-febe-414f-9bb4-99e7baf59ef4</guid><dc:creator>Luke Wright</dc:creator><description>&lt;p&gt;&amp;nbsp;The task which is neither executing my last&amp;nbsp; in html coding program,It&amp;#39;s not in running about Create (task1_thread, &amp;quot;TASK1&amp;quot;, 128, p_context, high priority or equal priority task is executing appear under the&amp;nbsp; priority section. I have the learning option with experts at &lt;a href="https://www.dissertationplanet.co.uk/"&gt;Phd dissertation writing service&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to create two task with different task priority?</title><link>https://devzone.nordicsemi.com/thread/123529?ContentTypeID=1</link><pubDate>Fri, 09 Mar 2018 02:03:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e63585b9-2f74-4fed-8a4f-98c42a21611d</guid><dc:creator>Cooper</dc:creator><description>&lt;p&gt;My test code is really&amp;nbsp;simple like below.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;task1.c&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;quot;task1.h&amp;quot;

#include &amp;quot;FreeRTOS.h&amp;quot;
#include &amp;quot;task.h&amp;quot;
#include &amp;quot;semphr.h&amp;quot;

#include &amp;quot;nrf_drv_gpiote.h&amp;quot;

static TaskHandle_t m_task1_thread;
SemaphoreHandle_t task1_sem;

static void task1_thread(void * arg)
{
	task1_sem = xSemaphoreCreateBinary();
	if (NULL == task1_sem)
	{
			APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
	}
	
	uint32_t err_code;
	nrf_drv_gpiote_out_config_t pin_config = GPIOTE_CONFIG_OUT_SIMPLE(false);
	err_code = nrf_drv_gpiote_out_init(LED_4, &amp;amp;pin_config);
	APP_ERROR_CHECK(err_code);
	
	while(1)
	{
		xSemaphoreTake(task1_sem, 1024);
		
		nrf_drv_gpiote_out_toggle(LED_4);
	}
}

void task1_thread_init(void * p_context)
{
	if (pdPASS != xTaskCreate(task1_thread, &amp;quot;TASK1&amp;quot;, 128, p_context, 1, &amp;amp;m_task1_thread))
    {
        APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
    }
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;task2.c&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;quot;task2.h&amp;quot;

#include &amp;quot;FreeRTOS.h&amp;quot;
#include &amp;quot;task.h&amp;quot;
#include &amp;quot;semphr.h&amp;quot;

#include &amp;quot;nrf_drv_gpiote.h&amp;quot;

static TaskHandle_t m_task2_thread;
SemaphoreHandle_t task2_sem;

static void task2_thread(void * arg)
{
	task2_sem = xSemaphoreCreateBinary();
	if (NULL == task2_sem)
	{
		APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
	}
	
	uint32_t err_code;
	nrf_drv_gpiote_out_config_t pin_config = GPIOTE_CONFIG_OUT_SIMPLE(false);
	err_code = nrf_drv_gpiote_out_init(LED_3, &amp;amp;pin_config);
	APP_ERROR_CHECK(err_code);
	
	while(1)
	{
		xSemaphoreTake(task2_sem, 512));
		
		nrf_drv_gpiote_out_toggle(LED_3);
	}
}

void task2_thread_init(void * p_context)
{
		if (pdPASS != xTaskCreate(task2_thread, &amp;quot;TASK2&amp;quot;, 128, p_context, 2, &amp;amp;m_task2_thread))
    {
        APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
    }
}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to create two task with different task priority?</title><link>https://devzone.nordicsemi.com/thread/123357?ContentTypeID=1</link><pubDate>Thu, 08 Mar 2018 08:19:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cc381da2-3567-49e9-a3aa-ab80d283454d</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;can you add the code for&amp;nbsp;m_task1_thread and&amp;nbsp;m_task2_thread? so that i can run them on my desk .&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>