<?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>Bluetooth UART Service Crash when processing data in the main task</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/94495/bluetooth-uart-service-crash-when-processing-data-in-the-main-task</link><description>Hi there, 
 We have tried to implement the bluetooth uart service with the standard example project (ble_app_uart). Up to this point everything works well. But for a custom solution we need to make some adjustments. 
 
 For security reasons, the bluetooth</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 16 Dec 2022 14:15:16 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/94495/bluetooth-uart-service-crash-when-processing-data-in-the-main-task" /><item><title>RE: Bluetooth UART Service Crash when processing data in the main task</title><link>https://devzone.nordicsemi.com/thread/401089?ContentTypeID=1</link><pubDate>Fri, 16 Dec 2022 14:15:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4a1c374f-b5f9-4671-a985-b271f6be2d82</guid><dc:creator>M. Schuurmans</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/00644.main.c"&gt;devzone.nordicsemi.com/.../00644.main.c&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bluetooth UART Service Crash when processing data in the main task</title><link>https://devzone.nordicsemi.com/thread/401088?ContentTypeID=1</link><pubDate>Fri, 16 Dec 2022 14:14:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ea705f1c-9efb-4e99-8e25-be257706cb11</guid><dc:creator>M. Schuurmans</dc:creator><description>&lt;p&gt;It became easier with the RTT debugging. Thanks for the tip, this was very helpfull. The printig of data always stoped when entering the advertising_stop function.&amp;nbsp;sd_ble_gap_disconnect() worked fine but the sd_ble_gap_adv_stop() function returned an error code. I found a support ticket with the same issue. I would have liked to share it but I can&amp;#39;t find the link anymore. So the advertising can&amp;#39;t be started if the device is already in the advertising mode. It also can&amp;#39;t be stopped if it is already stopped. This causes the error. The advertising stops after a defined timeout or after a connection is established. I added a is_advertising bool to the programm which holds track of the current advertising state. Now everything works fine. I&amp;#39;ll add the code for more clarity. I hope it helps someone else across his journey. Thanks for the support. See you in the next one ;)&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Maikel&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bluetooth UART Service Crash when processing data in the main task</title><link>https://devzone.nordicsemi.com/thread/400883?ContentTypeID=1</link><pubDate>Thu, 15 Dec 2022 14:37:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:744f9734-2a68-4e0f-aab3-06a9cfb156b7</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="M. Schuurmans"]The hardFault handler function are not getting invoked however. I added a debug point at the start of the HardFault_c_handler() function. No responds.[/quote]
&lt;p&gt;I see. Are you still reaching the other (default) hardfault hander? If so, it would indicate that either some of the two needed files are missing, or that&amp;nbsp;HARDFAULT_HANDLER_ENABLED is not set to 1 in sdk_config.h, or that there is no hardfault at this point.&lt;/p&gt;
[quote user="M. Schuurmans"]1. Does the APP_ERROR_CHECK() function prevent a HardFault?[/quote]
&lt;p&gt;No,&amp;nbsp;APP_ERROR_CHECK() checks the value that is passed to it, which should be the return value from a function. If this is not 0, it will act accordingly (typically log an error, and for release builds, reset in order to recover). This is important both for assisting in testing/debugging, and for recovering from otherwise unhanded errors. It does not prevent a hardfault in itself (though perhaps, if you ignore errors it could be that things escalate futher, and you end up with a hardfault later down the line).&lt;/p&gt;
[quote user="M. Schuurmans"]2. Is something wrong with my advertising_stop() function?&amp;nbsp;[/quote]
&lt;p&gt;It looks good to me.&lt;/p&gt;
[quote user="M. Schuurmans"]I was able to isolate a code segment that made the programm stop. Its the advertising_stop() function.&amp;nbsp;[/quote]
&lt;p&gt;How did you do that? Can you elaborate? (particularly as I am not able to see anything out of the ordinary in this function).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bluetooth UART Service Crash when processing data in the main task</title><link>https://devzone.nordicsemi.com/thread/400380?ContentTypeID=1</link><pubDate>Tue, 13 Dec 2022 12:47:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ae218fb8-3ae1-4de5-8487-cfa8e59fd36e</guid><dc:creator>M. Schuurmans</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/56422.main.c"&gt;devzone.nordicsemi.com/.../56422.main.c&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bluetooth UART Service Crash when processing data in the main task</title><link>https://devzone.nordicsemi.com/thread/400379?ContentTypeID=1</link><pubDate>Tue, 13 Dec 2022 12:46:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d8e8d43d-da80-4bea-b838-22038c49f308</guid><dc:creator>M. Schuurmans</dc:creator><description>&lt;p&gt;/**@brief Funtion for stoping advertising.&lt;br /&gt; */&lt;br /&gt;static void advertising_stop() //TODO: Test this function&lt;br /&gt;{&lt;br /&gt;if(bluetoothEN)&lt;br /&gt;{&lt;br /&gt;NRF_LOG_INFO(&amp;quot;Advertising stop\n&amp;quot;);&lt;br /&gt;if (m_conn_handle != BLE_CONN_HANDLE_INVALID)&lt;br /&gt;{&lt;br /&gt; uint32_t err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_CONN_INTERVAL_UNACCEPTABLE);&lt;br /&gt; APP_ERROR_CHECK(err_code);&lt;br /&gt; }&lt;br /&gt; uint32_t err_code = sd_ble_gap_adv_stop(m_advertising.adv_handle);&lt;br /&gt; if(err_code != NRF_SUCCESS)&lt;br /&gt; {&lt;br /&gt; APP_ERROR_CHECK(err_code);&lt;br /&gt; &lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt; bluetoothEN = false;&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt;}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bluetooth UART Service Crash when processing data in the main task</title><link>https://devzone.nordicsemi.com/thread/400378?ContentTypeID=1</link><pubDate>Tue, 13 Dec 2022 12:44:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:08be08c3-e6fc-490a-858d-388f55cf2e8e</guid><dc:creator>M. Schuurmans</dc:creator><description>&lt;p&gt;Ok, thanks for the info. I have enabled the Logging feature. I&amp;#39;m using the J-Link RTT. The NRF_LOG_INFO() macros are getting called in the regular functions. The hardFault handler function are not getting invoked however. I added a debug point at the start of the HardFault_c_handler() function. No responds.&lt;/p&gt;
&lt;p&gt;I was able to isolate a code segment that made the programm stop. Its the advertising_stop() function.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;1. Does the APP_ERROR_CHECK() function prevent a HardFault?&lt;/p&gt;
&lt;p&gt;2. Is something wrong with my advertising_stop() function?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll post the function and the main file for completeness.&lt;/p&gt;
&lt;p&gt;best regards Maikel&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bluetooth UART Service Crash when processing data in the main task</title><link>https://devzone.nordicsemi.com/thread/400174?ContentTypeID=1</link><pubDate>Mon, 12 Dec 2022 14:15:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6dbfb796-db22-42c8-b332-5d4ac5ef5017</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="M. Schuurmans"]Is it a replacement for the main function. Do I have to add it to some callback?[/quote]
&lt;p&gt;As long as you added the two implementation files and enabled HARDFAULT_HANDLER_ENABLED&amp;nbsp;in sdk_config.h that should be used (the default HardFault_Handler in the startup file is weak, so simply adding another will cause that to be used). There is no need to make any other changes in your project or code in order to use it. Is the&amp;nbsp;hardfault handler from the library not reached now?&lt;/p&gt;
[quote user="M. Schuurmans"]My main.c file still looks the same as befor.[/quote]
&lt;p&gt;That is good, as it should.&lt;/p&gt;
[quote user="M. Schuurmans"]The diffrence is that the exception no breaks at screenshot 2. I&amp;#39;m not sure how to progress from here. Thanks for the patience. Best regards Maikel[/quote]
&lt;p&gt;The new hardfault handle use logging, so if you have logging enabled it should be enough to observe the log output to see info about the hard fault (if you don&amp;#39;t have logging enabled, consider enabling it - it is often very usefull for debugging). If you are not able to get logging working you could set a breakpoint in the&amp;nbsp;HardFault_c_handler() function and inspect it manually to find the info that would normally be printed in the log.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bluetooth UART Service Crash when processing data in the main task</title><link>https://devzone.nordicsemi.com/thread/400090?ContentTypeID=1</link><pubDate>Mon, 12 Dec 2022 10:10:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:70445830-155a-4e38-9408-b2a753a9ede2</guid><dc:creator>M. Schuurmans</dc:creator><description>&lt;p&gt;Good morning, I hope you had a nice weekend. Yes you are right about the HardFault handler. It does get reached and enters this mode. I have set the &lt;span&gt;HARDFAULT_HANDLER_ENABLED&amp;nbsp;&lt;/span&gt;to 1 and added hardfault_implementation.c. I added hardfault_handler_keil.c because I am using the keil compiler. I&amp;#39;m not quite sure about how to use the HardFault_handler function tough. Is it a replacement for the main function. Do I have to add it to some callback? My main.c file still looks the same as befor. The diffrence is that the exception no breaks at screenshot 2. I&amp;#39;m not sure how to progress from here. Thanks for the patience. Best regards Maikel&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&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/4150.screenshot1.png" alt=" " /&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/1016.screenshot2.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bluetooth UART Service Crash when processing data in the main task</title><link>https://devzone.nordicsemi.com/thread/399868?ContentTypeID=1</link><pubDate>Fri, 09 Dec 2022 09:36:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eff916b1-e18a-459e-8067-05279b7a6f58</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I see that the hardfault handler is reached, but it is not easy to see much more from the video. I suggest that you add the hardfault handler from the SDK &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/lib_hardfault.html"&gt;HardFault handling library&lt;/a&gt;&amp;nbsp;and enable logging. To use it, set&amp;nbsp;HARDFAULT_HANDLER_ENABLED to 1 in sdk_config.h. Also, make sure you have hardfault_implementation.c and hardfault_handler_iar.c and that&amp;nbsp;components/libraries/hardfault/ is in your inlude path. Then enable logging. Then the log will provide information on the hardfault so that we know more where to look closer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bluetooth UART Service Crash when processing data in the main task</title><link>https://devzone.nordicsemi.com/thread/399753?ContentTypeID=1</link><pubDate>Thu, 08 Dec 2022 15:15:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e02afb0a-6b4e-417a-86e4-d95ae3e2b6be</guid><dc:creator>M. Schuurmans</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/bandicam-2022_2D00_12_2D00_08-15_2D00_57_2D00_44_2D00_277.mp4"&gt;devzone.nordicsemi.com/.../bandicam-2022_2D00_12_2D00_08-15_2D00_57_2D00_44_2D00_277.mp4&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not sure if this works but lets give it a try. So I have added the error check functions and the device enters the hard-fault handler after connecting to Windows. This doesn&amp;#39;t happen with nrf-connect. I&amp;#39;m aware that Nordic UART is a custom service. This test is only about making a connection to windows. I wasn&amp;#39;t able to find the entry point of the hard-fault handler. If this is even accessable and not a part of the softdevice. I&amp;#39;m sorry if my infomation is a little vague, I have just started to work with your chips.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bluetooth UART Service Crash when processing data in the main task</title><link>https://devzone.nordicsemi.com/thread/399726?ContentTypeID=1</link><pubDate>Thu, 08 Dec 2022 14:13:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d4457215-9321-4c99-8631-a53afa7f8f75</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;I am not sure exactly what freezes means here. What state is the device in? What doe sit do, and what should it have done? What have you found by debugging?&lt;/p&gt;
&lt;p&gt;Note the Nordic UART service is a custom service, so there is no native support for it in Windows.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bluetooth UART Service Crash when processing data in the main task</title><link>https://devzone.nordicsemi.com/thread/399693?ContentTypeID=1</link><pubDate>Thu, 08 Dec 2022 13:57:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5a92a49e-92c2-4f67-9c27-f5f17da1b2a0</guid><dc:creator>M. Schuurmans</dc:creator><description>&lt;p&gt;So, I have disabled the optimizations. It was set to O1. The device works now with NRF connect, as it should. It still Freezes when connecting to Windows tough. Is this a known issue? It seems strange to me. For context, I only use the Windows bluetooth connection manager in the settings (Win11).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bluetooth UART Service Crash when processing data in the main task</title><link>https://devzone.nordicsemi.com/thread/399658?ContentTypeID=1</link><pubDate>Thu, 08 Dec 2022 12:40:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6209ff92-6d8a-4881-b3ae-c512258b2f29</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Yes,&amp;nbsp;sd_ble_gap_adv_stop is supported in S132. If the project built without warnings (which it should always do!) that should not be a problem. However, this makes me wonder if you have optimizations enabled? While debugging that can cause problems as the machine code could be quite far from the C code, so it could be that you should disable optimization while debugging. If you are using a Segger embedded studio project based on an SDK example, you probably have a &amp;quot;Debug&amp;quot; build target that you can select. If not, just make sure to disable optimization (set it to 0) in whichever toolchain/IDE you are using.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bluetooth UART Service Crash when processing data in the main task</title><link>https://devzone.nordicsemi.com/thread/399649?ContentTypeID=1</link><pubDate>Thu, 08 Dec 2022 12:33:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:68b60881-c515-47b8-933c-72c65270cdfd</guid><dc:creator>M. Schuurmans</dc:creator><description>&lt;p&gt;So I have debugged the code and it seems as if the code gets stuck with the sd_ble_gap_adv_stop function. The IDE can&amp;#39;t find the function which is weird because i have added the ble_gap header file. I&amp;#39;m using the pca10040_s132 softdevice. Does this support this function?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards Maikel&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bluetooth UART Service Crash when processing data in the main task</title><link>https://devzone.nordicsemi.com/thread/399028?ContentTypeID=1</link><pubDate>Mon, 05 Dec 2022 15:56:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b9faa3ce-4882-4b13-9f72-e1f65f13d8ae</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Diffing the two sections, I see that&amp;nbsp;this is your main loop when it fails:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;	for (;;)
	{		
		static uint32_t var;
		static uint32_t varOld;
		const uint32_t deltaVar = 32768;
		var = NRF_RTC0-&amp;gt;COUNTER;
	
		if((var-varOld) &amp;gt; deltaVar)
		{
			varOld = var;
			idleCounter++;
		
			nrf_gpio_pin_toggle(LED_GREEN);

			if(idleCounter &amp;gt; 3600)
			{
				idleCounter = 0;
				uartDevice.uartOutputState = idle;
			}
			if(uartDevice.uartOutputState == idle)
			{				
				advertising_stop();
				idleHandler();
			}
		}
		else if(uartDevice.uartOutputState == Bluetooth)
		{
			advertising_start();
			idle_state_handle();
		}	
	}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;In the non-failing variant the main loop only includes a call to&amp;nbsp;idle_state_handle().&lt;/p&gt;
&lt;p&gt;I still want to know more about how it fails, though. Can you try to debug and see what happens? Is an error handler called, or something else? Please elaborate on this point, as that debugging properly to see what actually happens will surely save time in the long run.&lt;/p&gt;
&lt;p&gt;Without any hard information from debugging I only have some generic thoughts.&amp;nbsp;It could be an error handler that is hit, some issue with the logic you check (with your&amp;nbsp;deltaVar), or something else. Focusing on the LED, that is basically only controlled by the logic with your val, varOld and deltaVar. Or perhaps after entering sleep, there is nothing that wakes the device up (not events/interrupts)? Debugging should provide quick answers.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bluetooth UART Service Crash when processing data in the main task</title><link>https://devzone.nordicsemi.com/thread/399021?ContentTypeID=1</link><pubDate>Mon, 05 Dec 2022 15:09:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1c693097-35c0-4415-9c91-9e9c596bb988</guid><dc:creator>M. Schuurmans</dc:creator><description>[quote userid="7377" url="~/f/nordic-q-a/94495/bluetooth-uart-service-crash-when-processing-data-in-the-main-task/398990"] what happens when tings seems to &amp;quot;crash&amp;quot;?[/quote]
&lt;p&gt;So the Bluetooth device doesn&amp;#39;t respond to any inputs. The LED that gets toggled freezes. The device doesn&amp;#39;t hit any breakpoint. Its as if the device doesn&amp;#39;t handle any inputs anymore.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bluetooth UART Service Crash when processing data in the main task</title><link>https://devzone.nordicsemi.com/thread/399019?ContentTypeID=1</link><pubDate>Mon, 05 Dec 2022 15:06:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f35a8802-2ce9-45e9-bf30-c07127e2c425</guid><dc:creator>M. Schuurmans</dc:creator><description>&lt;p&gt;/////////////////////&lt;/p&gt;
&lt;p&gt;// This works&lt;/p&gt;
&lt;p&gt;////////////////////&lt;/p&gt;
&lt;p&gt;int main(void)&lt;br /&gt;{&lt;br /&gt; bool erase_bonds;&lt;br /&gt; //////////////////////////////////////////&lt;br /&gt; // Initialize UART and generic periferals&lt;br /&gt; //////////////////////////////////////////&lt;br /&gt; uartDevice.uartOutputState = Bluetooth;&amp;nbsp;&lt;br /&gt; &lt;br /&gt; led_init();&lt;br /&gt; uart_init();&lt;br /&gt; power_management_init();&lt;br /&gt; configureBluetoothName(); &lt;br /&gt; //timers_init();&lt;br /&gt; &lt;br /&gt; //log_init();&lt;br /&gt; //buttons_leds_init(&amp;amp;erase_bonds);&lt;br /&gt; &lt;br /&gt; //////////////////////////////////////////&lt;br /&gt; // Initialize Bluetooth specific functions&lt;br /&gt; //////////////////////////////////////////&lt;br /&gt; ble_stack_init();&lt;br /&gt; gap_params_init();&lt;br /&gt; gatt_init();&lt;br /&gt; services_init();&lt;br /&gt; advertising_init();&lt;br /&gt; conn_params_init();&lt;/p&gt;
&lt;p&gt;advertising_start();&lt;/p&gt;
&lt;p&gt;//////////////////////////////////////////&lt;br /&gt; // Enter main loop&lt;br /&gt; //////////////////////////////////////////&lt;br /&gt; for (;;)&lt;br /&gt; { &lt;br /&gt; idle_state_handle();&lt;br /&gt; }&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;/////////////////////////&lt;/p&gt;
&lt;p&gt;// This doesn&amp;#39;t&lt;/p&gt;
&lt;p&gt;////////////////////////&lt;/p&gt;
&lt;p&gt;int main(void)&lt;br /&gt;{&lt;br /&gt; bool erase_bonds;&lt;br /&gt; //////////////////////////////////////////&lt;br /&gt; // Initialize UART and generic periferals&lt;br /&gt; //////////////////////////////////////////&lt;br /&gt; uartDevice.uartOutputState = Bluetooth; //Only for test purpouses&lt;br /&gt; &lt;br /&gt; led_init();&lt;br /&gt; uart_init();&lt;br /&gt; power_management_init();&lt;br /&gt; configureBluetoothName(); &lt;br /&gt; //timers_init();&lt;br /&gt; &lt;br /&gt; //log_init();&lt;br /&gt; //buttons_leds_init(&amp;amp;erase_bonds);&lt;br /&gt; &lt;br /&gt; //////////////////////////////////////////&lt;br /&gt; // Initialize Bluetooth specific functions&lt;br /&gt; //////////////////////////////////////////&lt;br /&gt; ble_stack_init();&lt;br /&gt; gap_params_init();&lt;br /&gt; gatt_init();&lt;br /&gt; services_init();&lt;br /&gt; advertising_init();&lt;br /&gt; conn_params_init();&lt;/p&gt;
&lt;p&gt;advertising_start();&lt;/p&gt;
&lt;p&gt;//////////////////////////////////////////&lt;br /&gt; // Enter main loop&lt;br /&gt; //////////////////////////////////////////&lt;br /&gt; for (;;)&lt;br /&gt; {&lt;br /&gt; static uint32_t var;&lt;br /&gt; static uint32_t varOld;&lt;br /&gt; const uint32_t deltaVar = 32768;&lt;br /&gt; var = NRF_RTC0-&amp;gt;COUNTER;&lt;br /&gt; &lt;br /&gt; if((var-varOld) &amp;gt; deltaVar)&lt;br /&gt; {&lt;br /&gt; varOld = var;&lt;br /&gt; idleCounter++;&lt;br /&gt; &lt;br /&gt; nrf_gpio_pin_toggle(LED_GREEN);&lt;br /&gt; &lt;br /&gt; if(idleCounter &amp;gt; 3600)&lt;br /&gt; {&lt;br /&gt; idleCounter = 0;&lt;br /&gt; uartDevice.uartOutputState = idle;&lt;br /&gt; }&lt;br /&gt; if(uartDevice.uartOutputState == idle)&lt;br /&gt; { &lt;br /&gt; advertising_stop();&lt;br /&gt; idleHandler();&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; else if(uartDevice.uartOutputState == Bluetooth)&lt;br /&gt; {&lt;br /&gt; advertising_start();&lt;br /&gt; idle_state_handle();&lt;br /&gt; } &lt;br /&gt; &lt;br /&gt; }&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bluetooth UART Service Crash when processing data in the main task</title><link>https://devzone.nordicsemi.com/thread/398990?ContentTypeID=1</link><pubDate>Mon, 05 Dec 2022 13:45:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d44ea923-8409-43f4-9517-3bd285f75cf2</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Can you elaborate on what happens when tings seems to &amp;quot;crash&amp;quot;? Is an error check hit, or&amp;nbsp;something else? What have you found by debugging?&amp;nbsp;&lt;/p&gt;
[quote user=""]When these are removed, everything works fine again.[/quote]
&lt;p&gt;Can you clarify exactly what you remove to workaround the issue? Which line(s) of your main.c do you need to comment out, or similar?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>