<?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>Initialization of the UART when the system starts up</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/82490/initialization-of-the-uart-when-the-system-starts-up</link><description>I have developed a project using 9160. When I start up with the client board, the log will show that at command execution error occurs when I start up. Why is this? I admit that WHEN I start up, I perform some operations on NVS first, and then a few seconds</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 14 Dec 2021 17:32:39 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/82490/initialization-of-the-uart-when-the-system-starts-up" /><item><title>RE: Initialization of the UART when the system starts up</title><link>https://devzone.nordicsemi.com/thread/343491?ContentTypeID=1</link><pubDate>Tue, 14 Dec 2021 17:32:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5c522540-fbd7-45cf-adea-484dbe82828d</guid><dc:creator>Hakon</dc:creator><description>[quote user="duxinglang"]Hi, the ncs verson is v1.2.0.[/quote]
&lt;p&gt;That&amp;#39;s quite old. Have you tried upgrading to a more recent release, like 1.7.1?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Initialization of the UART when the system starts up</title><link>https://devzone.nordicsemi.com/thread/342810?ContentTypeID=1</link><pubDate>Fri, 10 Dec 2021 05:55:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3f7e40ca-1571-4dbe-8cd2-168167415ce3</guid><dc:creator>duxinglang</dc:creator><description>&lt;p&gt;Hi, the ncs verson is v1.2.0. My code for start up is fllow:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void system_init(void)
{
#ifdef CONFIG_FOTA_DOWNLOAD
	fota_init();
#endif

	InitSystemSettings();
	
	pmu_init();
	LCD_Init();
	
	ShowBootUpLogo();

	key_init();
#ifdef CONFIG_AUDIO_SUPPORT	
	audio_init();
#endif
	ble_init();
#ifdef CONFIG_PPG_SUPPORT	
	PPG_init();
#endif
#ifdef CONFIG_IMU_SUPPORT
	IMU_init(&amp;amp;imu_work_q);
#endif
	NB_init(&amp;amp;nb_work_q);
	GPS_init(&amp;amp;gps_work_q);
}

void work_init(void)
{
	k_work_q_start(&amp;amp;nb_work_q, nb_stack_area,
					K_THREAD_STACK_SIZEOF(nb_stack_area),
					CONFIG_APPLICATION_WORKQUEUE_PRIORITY);
#ifdef CONFIG_IMU_SUPPORT	
	k_work_q_start(&amp;amp;imu_work_q, imu_stack_area,
					K_THREAD_STACK_SIZEOF(imu_stack_area),
					CONFIG_APPLICATION_WORKQUEUE_PRIORITY);
#endif
	k_work_q_start(&amp;amp;gps_work_q, gps_stack_area,
					K_THREAD_STACK_SIZEOF(gps_stack_area),
					CONFIG_APPLICATION_WORKQUEUE_PRIORITY);	
	
	if(IS_ENABLED(CONFIG_WATCHDOG))
	{
		watchdog_init_and_start(&amp;amp;k_sys_work_q);
	}
}

int main(void)
{
	work_init();
	system_init();

	while(1)
	{
		KeyMsgProcess();
		TimeMsgProcess();
		NBMsgProcess();
	#ifdef CONFIG_WIFI	
		WifiProcess();
	#endif
		GPSMsgProcess();
		PMUMsgProcess();
	#ifdef CONFIG_IMU_SUPPORT	
		IMUMsgProcess();
		FallMsgProcess();
	#endif
	#ifdef CONFIG_PPG_SUPPORT	
		PPGMsgProcess();
	#endif
		LCDMsgProcess();
	#ifdef CONFIG_TOUCH_SUPPORT
		TPMsgProcess();
	#endif
		AlarmMsgProcess();
		SettingsMsgPorcess();
		SOSMsgProc();
		UartMsgProc();
		ScreenMsgProcess();
	#ifdef CONFIG_FOTA_DOWNLOAD
		FotaMsgProc();
	#endif
	#ifdef CONFIG_AUDIO_SUPPORT
		AudioMsgProcess();
	#endif
	#ifdef CONFIG_ANIMATION_SUPPORT
		AnimaMsgProcess();
	#endif
		system_init_completed();
		k_cpu_idle();
	}
}

static void modem_init(struct k_work *work)
{
	SetModemTurnOn();

	k_delayed_work_submit_to_queue(app_work_q, &amp;amp;nb_link_work, K_SECONDS(2));
}


static void nb_link(struct k_work *work)
{
	int err=0;
	u8_t tmpbuf[128] = {0};
	static u32_t retry_count = 0;
	static bool frist_flag = false;

	if(!frist_flag)
	{
		frist_flag = true;
		GetModemInfor();
		SetModemTurnOff();
		if(strlen(g_imsi) &amp;gt; 0)
		{
			err = lte_lc_init();
			LOGD(&amp;quot;lte_lc_init err:%d&amp;quot;, err);
		}
		else
		{
			LOGD(&amp;quot;Get imsi fail, will not link network!&amp;quot;);
		}
	}

	if(gps_is_working())
	{
		LOGD(&amp;quot;gps is working, continue waiting!&amp;quot;);

		if(retry_count &amp;lt;= 2)		//2&amp;#180;&amp;#206;&amp;#210;&amp;#212;&amp;#196;&amp;#218;&amp;#195;&amp;#191;1&amp;#183;&amp;#214;&amp;#214;&amp;#211;&amp;#214;&amp;#216;&amp;#193;&amp;#172;&amp;#210;&amp;#187;&amp;#180;&amp;#206;
			k_timer_start(&amp;amp;nb_reconnect_timer, K_SECONDS(60), NULL);
		else if(retry_count &amp;lt;= 4)	//3&amp;#181;&amp;#189;4&amp;#180;&amp;#206;&amp;#195;&amp;#191;5&amp;#183;&amp;#214;&amp;#214;&amp;#211;&amp;#214;&amp;#216;&amp;#193;&amp;#172;&amp;#210;&amp;#187;&amp;#180;&amp;#206;
			k_timer_start(&amp;amp;nb_reconnect_timer, K_SECONDS(300), NULL);
		else if(retry_count &amp;lt;= 6)	//5&amp;#181;&amp;#189;6&amp;#180;&amp;#206;&amp;#195;&amp;#191;10&amp;#183;&amp;#214;&amp;#214;&amp;#211;&amp;#214;&amp;#216;&amp;#193;&amp;#172;&amp;#210;&amp;#187;&amp;#180;&amp;#206;
			k_timer_start(&amp;amp;nb_reconnect_timer, K_SECONDS(600), NULL);
		else if(retry_count &amp;lt;= 8)	//7&amp;#181;&amp;#189;8&amp;#180;&amp;#206;&amp;#195;&amp;#191;1&amp;#208;&amp;#161;&amp;#202;&amp;#177;&amp;#214;&amp;#216;&amp;#193;&amp;#172;&amp;#210;&amp;#187;&amp;#180;&amp;#206;
			k_timer_start(&amp;amp;nb_reconnect_timer, K_SECONDS(3600), NULL);
		else						//8&amp;#180;&amp;#206;&amp;#210;&amp;#212;&amp;#201;&amp;#207;&amp;#195;&amp;#191;6&amp;#208;&amp;#161;&amp;#202;&amp;#177;&amp;#214;&amp;#216;&amp;#193;&amp;#172;&amp;#210;&amp;#187;&amp;#180;&amp;#206;
			k_timer_start(&amp;amp;nb_reconnect_timer, K_SECONDS(6*3600), NULL);	
	}
	else
	{
		LOGD(&amp;quot;linking&amp;quot;);
		nb_connecting_flag = true;
	#ifdef CONFIG_DEVICE_POWER_MANAGEMENT
		uart_sleep_out();
	#endif
		//configure_low_power();

		err = lte_lc_connect();
		if(err)
		{
			LOGD(&amp;quot;Can&amp;#39;t connected to LTE network. err:%d&amp;quot;, err);
			nb_connected = false;

			retry_count++;
			if(retry_count &amp;lt;= 2)		//2&amp;#180;&amp;#206;&amp;#210;&amp;#212;&amp;#196;&amp;#218;&amp;#195;&amp;#191;1&amp;#183;&amp;#214;&amp;#214;&amp;#211;&amp;#214;&amp;#216;&amp;#193;&amp;#172;&amp;#210;&amp;#187;&amp;#180;&amp;#206;
				k_timer_start(&amp;amp;nb_reconnect_timer, K_SECONDS(60), NULL);
			else if(retry_count &amp;lt;= 4)	//3&amp;#181;&amp;#189;4&amp;#180;&amp;#206;&amp;#195;&amp;#191;5&amp;#183;&amp;#214;&amp;#214;&amp;#211;&amp;#214;&amp;#216;&amp;#193;&amp;#172;&amp;#210;&amp;#187;&amp;#180;&amp;#206;
				k_timer_start(&amp;amp;nb_reconnect_timer, K_SECONDS(300), NULL);
			else if(retry_count &amp;lt;= 6)	//5&amp;#181;&amp;#189;6&amp;#180;&amp;#206;&amp;#195;&amp;#191;10&amp;#183;&amp;#214;&amp;#214;&amp;#211;&amp;#214;&amp;#216;&amp;#193;&amp;#172;&amp;#210;&amp;#187;&amp;#180;&amp;#206;
				k_timer_start(&amp;amp;nb_reconnect_timer, K_SECONDS(600), NULL);
			else if(retry_count &amp;lt;= 8)	//7&amp;#181;&amp;#189;8&amp;#180;&amp;#206;&amp;#195;&amp;#191;1&amp;#208;&amp;#161;&amp;#202;&amp;#177;&amp;#214;&amp;#216;&amp;#193;&amp;#172;&amp;#210;&amp;#187;&amp;#180;&amp;#206;
				k_timer_start(&amp;amp;nb_reconnect_timer, K_SECONDS(3600), NULL);
			else						//8&amp;#180;&amp;#206;&amp;#210;&amp;#212;&amp;#201;&amp;#207;&amp;#195;&amp;#191;6&amp;#208;&amp;#161;&amp;#202;&amp;#177;&amp;#214;&amp;#216;&amp;#193;&amp;#172;&amp;#210;&amp;#187;&amp;#180;&amp;#206;
				k_timer_start(&amp;amp;nb_reconnect_timer, K_SECONDS(6*3600), NULL);
		}
		else
		{
			LOGD(&amp;quot;Connected to LTE network&amp;quot;);

			nb_connected = true;
			retry_count = 0;

			GetModemDateTime();
			modem_data_init();
		}

		GetModemStatus();

		if(!nb_connected)
			SetModemTurnOff();
		
		if(!err &amp;amp;&amp;amp; !test_nb_flag)
		{
			k_delayed_work_submit_to_queue(app_work_q, &amp;amp;mqtt_link_work, K_SECONDS(2));
		}

		nb_connecting_flag = false;
	}
}
void NB_init(struct k_work_q *work_q)
{
	int err;

	app_work_q = work_q;

	k_delayed_work_init(&amp;amp;modem_init_work, modem_init);
	k_delayed_work_init(&amp;amp;nb_link_work, nb_link);
	k_delayed_work_init(&amp;amp;mqtt_link_work, mqtt_link);
#ifdef CONFIG_FOTA_DOWNLOAD
	fota_work_init(work_q);
#endif

	k_delayed_work_submit_to_queue(app_work_q, &amp;amp;modem_init_work, K_SECONDS(5));
}
&lt;/pre&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Initialization of the UART when the system starts up</title><link>https://devzone.nordicsemi.com/thread/342428?ContentTypeID=1</link><pubDate>Tue, 07 Dec 2021 17:19:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:984ae299-cd69-4816-8508-132b42775e68</guid><dc:creator>Hakon</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;what is the NCS version? Can you share the code?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>