<?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 properly switch between UART pins and baud rates with nRF52 (UARTE)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/19525/how-to-properly-switch-between-uart-pins-and-baud-rates-with-nrf52-uarte</link><description>Hey. 
 I have a GPS chip which uses 57600 baud for its rx pin, and 115200 baud for its TX pin.
I need to switch between the two baud rates, and also some times connect to a third RX pin. 
 I am using the uart driver ( nrf_drv_uart ), with UARTE and</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 01 Mar 2021 06:41:17 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/19525/how-to-properly-switch-between-uart-pins-and-baud-rates-with-nrf52-uarte" /><item><title>RE: How to properly switch between UART pins and baud rates with nRF52 (UARTE)</title><link>https://devzone.nordicsemi.com/thread/296739?ContentTypeID=1</link><pubDate>Mon, 01 Mar 2021 06:41:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9bad58c5-bcd2-4c12-863b-cdd3f3eebd65</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/rixtronixlab"&gt;RixtronixLAB&lt;/a&gt;: If you take a look at the&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/group__nrfx__uart.html#gad39364c2398152822f0a7cf08242c773"&gt;nrfx_uart_init&lt;/a&gt;&lt;span&gt;&amp;nbsp;function in the UART Driver API, then you can see that you need to provide a UART instance as a parameter, which points to the UART peripheral you want to use.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;You create an instance&amp;nbsp;with the&amp;nbsp; &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/group__nrfx__uart.html#gaedde27dbdcd78002a3db52874954fcb8"&gt;NRFX_UART_INSTANCE&lt;/a&gt;&amp;nbsp;macro and you can see the available instances for the nRF52840 under &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/keyfeatures_html5.html"&gt;nRF52840 Product Specification&lt;/a&gt;&amp;nbsp;&amp;gt;&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/nav/4_0_0_3"&gt;Core components&lt;/a&gt;&amp;nbsp;&amp;gt;&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/memory.html"&gt;Memory&lt;/a&gt;&amp;nbsp;&amp;gt;&lt;a title="Instantiation" href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/memory.html?cp=4_0_0_3_1_3#topic"&gt;Instantiation&lt;/a&gt;.&amp;nbsp;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;So if you want to use UARTE0 you pass 0 as the ID to the&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/group__nrfx__uart.html#gaedde27dbdcd78002a3db52874954fcb8"&gt;NRFX_UART_INSTANCE&lt;/a&gt;&amp;nbsp;macro, if you want to use&amp;nbsp;UARTE1, then you pass 1 to the&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/group__nrfx__uart.html#gaedde27dbdcd78002a3db52874954fcb8"&gt;NRFX_UART_INSTANCE&lt;/a&gt;&amp;nbsp;macro.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Bjørn&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to properly switch between UART pins and baud rates with nRF52 (UARTE)</title><link>https://devzone.nordicsemi.com/thread/291384?ContentTypeID=1</link><pubDate>Tue, 26 Jan 2021 22:17:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:196c6894-69b8-47ee-8724-c9445e972761</guid><dc:creator>RixtronixLAB</dc:creator><description>&lt;p&gt;How do you initialize 2 UARTs ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to properly switch between UART pins and baud rates with nRF52 (UARTE)</title><link>https://devzone.nordicsemi.com/thread/75878?ContentTypeID=1</link><pubDate>Tue, 18 Apr 2017 11:06:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a6be14e5-2bac-46a9-bf90-6020ca366268</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Happy to help :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to properly switch between UART pins and baud rates with nRF52 (UARTE)</title><link>https://devzone.nordicsemi.com/thread/75877?ContentTypeID=1</link><pubDate>Tue, 18 Apr 2017 10:56:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9d746db6-757e-4d7b-8572-eb2d3706007e</guid><dc:creator>Poonam</dc:creator><description>&lt;p&gt;yes, i m using gsm module. and this works . Thank u.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to properly switch between UART pins and baud rates with nRF52 (UARTE)</title><link>https://devzone.nordicsemi.com/thread/75883?ContentTypeID=1</link><pubDate>Tue, 18 Apr 2017 07:40:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5bbaa77c-1a92-4a59-8eef-222bfeefb22d</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Are you using a GPS module that outputs NMEA strings? If that is the case, then you can look for the  character, i.e. &lt;code&gt;&amp;quot;\n&amp;quot;&lt;/code&gt; which terminates every NMEA sentence to separate them from each other.  You can also look for the &amp;quot;$&amp;quot; at the start of each sentence.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void uart_event_handle(app_uart_evt_t * p_event)
{
    static uint8_t data_array[256];
    static uint8_t index = 0;
    uint32_t       err_code;

    switch (p_event-&amp;gt;evt_type)
    {
        case APP_UART_DATA_READY:
            UNUSED_VARIABLE(app_uart_get(&amp;amp;data_array[index]));
            index++;
       
            if ((data_array[index - 1] == &amp;#39;\n&amp;#39;))
            {
                \\ parse NMEA sentence here.
            }

                index = 0;
            }
            break;
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to properly switch between UART pins and baud rates with nRF52 (UARTE)</title><link>https://devzone.nordicsemi.com/thread/75882?ContentTypeID=1</link><pubDate>Tue, 18 Apr 2017 07:23:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:286f284b-f435-4b00-b8aa-33d0f0052fcb</guid><dc:creator>Poonam</dc:creator><description>&lt;p&gt;@Bjørn Spockeli : no i don,t have any provision for hardware flow control.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void uart_event_handler(nrf_drv_uart_event_t * p_event)
{
	if ( p_event -&amp;gt;type == NRF_DRV_UART_EVT_RX_DONE)
		{
			if(rx_index &amp;lt; 256)
			{
				app_uart_get(&amp;amp;gps_rx_buf[rx_index]);
				rx_index++;
			}
			else if (rx_index &amp;gt;= 256)
			{
				rx_index =0;
				app_uart_get(&amp;amp;gps_rx_buf[rx_index]);
				rx_index++;
			}
		}
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;is it fine ,if i used it like this?&lt;/p&gt;
&lt;p&gt;how to stop reception to avoid overlapping of data ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to properly switch between UART pins and baud rates with nRF52 (UARTE)</title><link>https://devzone.nordicsemi.com/thread/75881?ContentTypeID=1</link><pubDate>Tue, 18 Apr 2017 07:10:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:328f29f6-c380-4060-bd96-9b5eab7b6294</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;I recommend setting the RX buffer size equal to the largest string that you expect to receive. No, once 256 bytes has been received and you have not retrieved the data using app_uart_get, then you will get the APP_UART_FIFO_ERROR event, indicating that the FIFO is full.  Does the device you&amp;#39;re communicating with over UART support Hardware Flow Control? If yes, then the app_uart module will make sure that no that is sent if the buffer is full.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to properly switch between UART pins and baud rates with nRF52 (UARTE)</title><link>https://devzone.nordicsemi.com/thread/75880?ContentTypeID=1</link><pubDate>Tue, 18 Apr 2017 06:34:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aae4cdf1-7396-4954-a727-653e9845f0f3</guid><dc:creator>Poonam</dc:creator><description>&lt;p&gt;thank you @Bjørn Spockeli , i have one more question..i kept Rx buffer size 256 and i am receiving continuous data on UART . what if my data exceeds 256 bytes will it roll over automatically?
how can i disable reception when desired string is received?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to properly switch between UART pins and baud rates with nRF52 (UARTE)</title><link>https://devzone.nordicsemi.com/thread/75879?ContentTypeID=1</link><pubDate>Tue, 18 Apr 2017 06:16:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2804831c-55e8-4c3b-9f03-56e198a39456</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;@poonam: Yes, that should be possible, but you will have to use the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v12.0.0/group__app__uart.html#gae0ede683cca785a3706d8c3e465a1eb9"&gt;app_uart_init&lt;/a&gt; function directly and not the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v12.0.0/group__app__uart.html#gab37ec15202892ba42f454daacaa38b7f"&gt;APP_UART_FIFO_INIT()&lt;/a&gt; macro when switching between two instances.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to properly switch between UART pins and baud rates with nRF52 (UARTE)</title><link>https://devzone.nordicsemi.com/thread/75876?ContentTypeID=1</link><pubDate>Sat, 15 Apr 2017 11:32:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:64b1449b-ab49-40c7-bcd2-03fc9fa70a26</guid><dc:creator>Poonam</dc:creator><description>&lt;p&gt;I am also using nRf52832 DK , Can i use 2 uart instance using APP_UART_FIFO_INIT() and app_uart_close() ;  and then re-initialize the instance with the new configuration..........?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to properly switch between UART pins and baud rates with nRF52 (UARTE)</title><link>https://devzone.nordicsemi.com/thread/75875?ContentTypeID=1</link><pubDate>Tue, 07 Feb 2017 10:32:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fc048037-8614-40db-acd3-616635614e6e</guid><dc:creator>Anders Strand</dc:creator><description>&lt;p&gt;Thank you. Your assumption of me using the nRF52832 is correct :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to properly switch between UART pins and baud rates with nRF52 (UARTE)</title><link>https://devzone.nordicsemi.com/thread/75874?ContentTypeID=1</link><pubDate>Tue, 07 Feb 2017 10:19:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f0b108e9-f267-449f-a6aa-ff682d8c5169</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Hi Anders,&lt;/p&gt;
&lt;p&gt;I am assuming that you&amp;#39;re using the nRF52832, the multi-instance support in the UART driver is a nRF52840 specific feature since it has two UARTs. This is stated in the SDK v12.2.0 Release Notes, found &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v12.2.0/index.html?cp=4_0_1"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;So, if you need to change the configuration of your UART instance, you must un-initialize and then re-initialize the instance with the new configuration like you stated in your question. As far as I know the &lt;code&gt;nrf_drv_uart_init&lt;/code&gt; and &lt;code&gt;nrf_drv_uart_uninit&lt;/code&gt; calls are synchronous, so as soon as they have returned &lt;code&gt;NRF_SUCCESS&lt;/code&gt; you should be able to TX/RX with the new configuration.&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Bjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>