<?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>task threads blocking the device connection.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/64651/task-threads-blocking-the-device-connection</link><description>I&amp;#39;m using the NRF52840 SDK 15.0.0 
 I have 2 task threads and 5 ble services. 
 Now what happens is when I&amp;#39;m trying to connect the device with 2 tasks and ble services I&amp;#39;m unable to connect/pair the nrf52 device. 
 When I comment on one task the device</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 12 Aug 2020 04:35:40 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/64651/task-threads-blocking-the-device-connection" /><item><title>RE: task threads blocking the device connection.</title><link>https://devzone.nordicsemi.com/thread/264146?ContentTypeID=1</link><pubDate>Wed, 12 Aug 2020 04:35:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:561949aa-3d05-4d9c-996b-a37c3aa15190</guid><dc:creator>manoj97</dc:creator><description>&lt;p&gt;&lt;a href="https://www.freertos.org/RTOS-task-priority.html"&gt;https://www.freertos.org/RTOS-task-priority.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I referred the above link and given equal priority to the two tasks by enabling the &amp;quot;&lt;span&gt;configUSE_TIME_SLICING&amp;quot; from 0 to 1 in FreeRTOSConfig.h&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;it worked.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: task threads blocking the device connection.</title><link>https://devzone.nordicsemi.com/thread/264107?ContentTypeID=1</link><pubDate>Tue, 11 Aug 2020 14:12:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:63d5f003-410d-426d-8084-f41694a3112d</guid><dc:creator>Wavecake</dc:creator><description>&lt;p&gt;Use your debugger. Figure out where the program halts when the connection process fails. You should be able to tell if it is a memory issue or not. If the program hits the assert or goes to reset, you&amp;#39;ll know it&amp;#39;s a memory issue. If the debugger shows that the program continues to execute without issue, you&amp;#39;ll know it&amp;#39;s not a memory issue.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Definitely hook up the debugger and post your results.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: task threads blocking the device connection.</title><link>https://devzone.nordicsemi.com/thread/264105?ContentTypeID=1</link><pubDate>Tue, 11 Aug 2020 14:08:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c14a0b23-df05-4386-b154-f8fa661f4bd6</guid><dc:creator>Wavecake</dc:creator><description>&lt;p&gt;it doesn&amp;#39;t look like they are using the task manager. They are using the FreeRTOS API.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I think you brought up a good point though. For two tasks at the same level, one will need to yield.&amp;nbsp;In FreeRTOS you have the option to yield or add a delay. They delay effectively provides the yield. They have a delay in the device thread. They are missing a yield or a delay in the oled_thread.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Try adding taskYield or vTaskDelay()&amp;nbsp;to oled_thread.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not convinced this will solve the issue though. The connection process happens through interrupts, which supersede tasks in priority. They had a problem with the connection process.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: task threads blocking the device connection.</title><link>https://devzone.nordicsemi.com/thread/264096?ContentTypeID=1</link><pubDate>Tue, 11 Aug 2020 13:45:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:562ef31b-fc0c-48d1-9bf6-9aa8607f74ee</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;At what point in your threads do you call&amp;nbsp;&lt;a title="task_yield" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.0/group__task__manager.html?cp=7_1_6_10_17_12#gae92fe09f7ab93ec88821515714fb0926"&gt;task_yield&lt;/a&gt;&amp;nbsp;or &lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.0/group__task__manager.html#ga800b028431fd488a71fc739a36ebddc2"&gt;task_events_wait&lt;/a&gt;?&lt;br /&gt;&lt;br /&gt;&lt;a title="Experimental: Task manager" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.0/lib_task_manager.html?cp=7_1_3_58"&gt;From Experimental: Task manager&lt;/a&gt;&amp;nbsp;docs:&lt;br /&gt;&lt;br /&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.0/group__task__manager.html#ga53913a268d0922847748399771f349e3"&gt;task_create()&lt;/a&gt;&lt;span&gt;&amp;nbsp;creates and activates the task. If task is executed it will not be preempted by other task unless task explicitly triggers task switching. Task switch may be triggered by calling&amp;nbsp;&lt;/span&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.0/group__task__manager.html#gae92fe09f7ab93ec88821515714fb0926"&gt;task_yield()&lt;/a&gt;&lt;span&gt;&amp;nbsp;or&amp;nbsp;&lt;/span&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.0/group__task__manager.html#ga800b028431fd488a71fc739a36ebddc2"&gt;task_events_wait()&lt;/a&gt;&lt;span&gt;. If&amp;nbsp;&lt;/span&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.0/group__task__manager.html#gae92fe09f7ab93ec88821515714fb0926"&gt;task_yield()&lt;/a&gt;&lt;span&gt;&amp;nbsp;is called then task manager will switch to next active task. If there is no active task then switch will not occur. If&amp;nbsp;&lt;/span&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.0/group__task__manager.html#ga800b028431fd488a71fc739a36ebddc2"&gt;task_events_wait()&lt;/a&gt;&lt;span&gt;&amp;nbsp;is called then context switch will occur if there are no events waiting for the task.&amp;nbsp;&lt;/span&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.0/group__task__manager.html#ga800b028431fd488a71fc739a36ebddc2"&gt;task_events_wait()&lt;/a&gt;&lt;span&gt;&amp;nbsp;returns mask of events. Events are triggered by calling&amp;nbsp;&lt;/span&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.0/group__task__manager.html#gab4afa683b75510de63cf2d525da5eb2b"&gt;task_events_set()&lt;/a&gt;&lt;span&gt;&amp;nbsp;from any context.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: task threads blocking the device connection.</title><link>https://devzone.nordicsemi.com/thread/264065?ContentTypeID=1</link><pubDate>Tue, 11 Aug 2020 12:59:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4de269dc-e257-4898-aea8-f9a57af0c8dc</guid><dc:creator>manoj97</dc:creator><description>&lt;p&gt;sorry i didn&amp;#39;t get your point&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: task threads blocking the device connection.</title><link>https://devzone.nordicsemi.com/thread/263988?ContentTypeID=1</link><pubDate>Tue, 11 Aug 2020 09:34:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e4873862-6c29-471b-852f-80603692549a</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;At what points does your tasks yield?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: task threads blocking the device connection.</title><link>https://devzone.nordicsemi.com/thread/263985?ContentTypeID=1</link><pubDate>Tue, 11 Aug 2020 09:27:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d923488b-d7b2-4e8b-9335-0c0e4f5075ce</guid><dc:creator>manoj97</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt; //main.c
 void DeviceApplicationTask(void)
{
    if (pdPASS != xTaskCreate(device_thread, &amp;quot;device&amp;quot;, 256, NULL, 2, &amp;amp;m_device_thread))
    {
       APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
    }
}

void OLEDAutoRefreshTask(void)
{
    if (pdPASS != xTaskCreate(oled_thread, &amp;quot;device&amp;quot;, 256, NULL, 2, &amp;amp;m_oled_thread))
    {
       APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
    }
}

  main()
  {
    DeviceApplicationTask();
    OLEDAutoRefreshTask();
  }    &lt;/pre&gt;&lt;pre class="ui-code" data-mode="text"&gt;//oled.c
void oled_thread(void * arg)
{

   while(1)
   {
    menu_function(); //displays the screens when button press
    test_handler();   //handles the button operation
   }  
    nrf_delay_ms(200);

}
&lt;/pre&gt;&lt;pre class="ui-code" data-mode="text"&gt;//task_thread.c
void device_thread(void * arg)
{
        ret_code_t err_code;

      twi_init();
      while(1)
      {

          temperature_read();   //temperature read from sensor

          if(tmp_flg==1)
          {
          notify_tmp();
          }
         if(hum_flg==1)
         {
          notify_hum();
         }
          if(soc_flg==1)
         {
          notify_soc();
         }
          if(soh_flg==1)
         {
          notify_soh();
         }
          vTaskDelay(500);
               
      }  
}
  &lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: task threads blocking the device connection.</title><link>https://devzone.nordicsemi.com/thread/263977?ContentTypeID=1</link><pubDate>Tue, 11 Aug 2020 09:08:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8e8ce934-2d24-46f7-b6cb-1cd9609489e3</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;Can you share the two threads with us?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: task threads blocking the device connection.</title><link>https://devzone.nordicsemi.com/thread/263919?ContentTypeID=1</link><pubDate>Tue, 11 Aug 2020 05:27:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e0529f0f-dd5e-4e94-9c4a-fa2a0525a02e</guid><dc:creator>manoj97</dc:creator><description>&lt;p&gt;Present heap size is 1024&lt;/p&gt;
&lt;p&gt;stack size is 2048&lt;/p&gt;
&lt;p&gt;if I want to increase those size what is the value? how it is calculated?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;How did my firmware fail?&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;When I power ON my device and trying to connect my device with nrf connect application.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;When I click on connect in nrf connect application it will be in connecting state Foronly not able to connect the device you can see in below photo.&amp;nbsp;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;On application in logs I found this error: Error34(0x22):GATT CONN LMP TIMEOUT&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/2020_2D00_08_2D00_10.jpg" /&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;for this I tried to comment on one task then the device is connected immediately.&lt;/p&gt;
&lt;p&gt;This is the situation I want those tasks also.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: task threads blocking the device connection.</title><link>https://devzone.nordicsemi.com/thread/263892?ContentTypeID=1</link><pubDate>Mon, 10 Aug 2020 15:19:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cbc72658-d8ef-4d1f-baab-158632f74a61</guid><dc:creator>Wavecake</dc:creator><description>&lt;p&gt;Can you tell how your firmware fails?&amp;nbsp;A heap/memory problem would crash the firmware. Other kinds of problems may prevent&amp;nbsp;the connection, but you will still be able to confirm the firmware runs without issue by pausing and continuing the debugger.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: task threads blocking the device connection.</title><link>https://devzone.nordicsemi.com/thread/263878?ContentTypeID=1</link><pubDate>Mon, 10 Aug 2020 14:43:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fdfc63c8-9d20-425c-a7cd-0f24a612b6d4</guid><dc:creator>manoj97</dc:creator><description>&lt;p&gt;2 tasks&amp;nbsp;&lt;/p&gt;
&lt;p&gt;1) temperature and humidity sensor with I2c communication&lt;/p&gt;
&lt;p&gt;2) Oled connection with SPI communication.&lt;/p&gt;
&lt;p&gt;if I comment anyone peripherals/tasks device will be paired (ble_communication).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: task threads blocking the device connection.</title><link>https://devzone.nordicsemi.com/thread/263804?ContentTypeID=1</link><pubDate>Mon, 10 Aug 2020 11:39:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a174646f-3dce-49f5-85bb-8d04076d9ea7</guid><dc:creator>haakonsh</dc:creator><description>[quote user=""]When I comment on one task the device getting paired.[/quote]
&lt;p&gt;&amp;nbsp;Perhaps you care to share exactly what this task does?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>