<?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>Clarification of UART instances on NRF52840</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/94103/clarification-of-uart-instances-on-nrf52840</link><description>Hi. 
 I am developing a custom board using the NRF52840. The mcu needs to connect to a modem and a gnss module. Both modules will communicate with the mcu over UART 
 I&amp;#39;m using the app_uart API, and it&amp;#39;s not quite clear how to use this API with 2 instances</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 22 Nov 2022 13:03:37 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/94103/clarification-of-uart-instances-on-nrf52840" /><item><title>RE: Clarification of UART instances on NRF52840</title><link>https://devzone.nordicsemi.com/thread/396913?ContentTypeID=1</link><pubDate>Tue, 22 Nov 2022 13:03:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b0ec221a-8bf7-4e37-bf04-ddcf827d8f13</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;APP_UART uses hardcoded instance in app_uart.c and app_uart_fifo.c in the below line.&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;pre class="ui-code" data-mode="text"&gt;static nrf_drv_uart_t app_uart_inst = NRF_DRV_UART_INSTANCE(APP_UART_DRIVER_INSTANCE);&lt;/pre&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;It is a bit tricky to do multiple instances but it is possible. You need to have two instances of app_uart and edit the names like the API. For example you can have two new files into the project like&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/app_5F00_uart1.h"&gt;devzone.nordicsemi.com/.../app_5F00_uart1.h&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/app_5F00_uart1.c"&gt;devzone.nordicsemi.com/.../app_5F00_uart1.c&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Where I have changed the API in app_uart1.c to have app_uart1_init etc.&lt;/p&gt;
&lt;p&gt;I also have&amp;nbsp;app_uart_inst in app_uart1.c to use&amp;nbsp;APP_UART_DRIVER_INSTANCE_1 (instead of&amp;nbsp;APP_UART_DRIVER_INSTANCE) which you should add in your sdk_config.h file to use the second instance of the uart in app_uart1.c.&lt;/p&gt;
&lt;p&gt;And yes if you want app_uart to be used for two instances it is NOT possible without editing the libraries files.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Second way is to use app_uart for one instance and nrf_drv_uart directly for the second instance.&lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>