<?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>nRF9160 DK - UART big picture</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/88494/nrf9160-dk---uart-big-picture</link><description>Dear Nordic-Support Team, 
 Introduction 
 I have read through some sources (tickets and documentation) but I am still struggling to see the big picture of UART configuration in context of the nRF9160 DK. I noticed that even the terminology changes across</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 14 Jun 2022 10:55:06 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/88494/nrf9160-dk---uart-big-picture" /><item><title>RE: nRF9160 DK - UART big picture</title><link>https://devzone.nordicsemi.com/thread/372346?ContentTypeID=1</link><pubDate>Tue, 14 Jun 2022 10:55:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d1d125c-9976-4f90-902a-23b240d0bba4</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I&amp;#39;m glad we were able to help you and good luck with the project!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 DK - UART big picture</title><link>https://devzone.nordicsemi.com/thread/372336?ContentTypeID=1</link><pubDate>Tue, 14 Jun 2022 09:45:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:382fd331-9dcc-4718-a7b8-4fc25af57e02</guid><dc:creator>Sebastian Stein</dc:creator><description>&lt;p&gt;Hi Simon,&lt;/p&gt;
&lt;p&gt;thank you for your explanation.&lt;/p&gt;
[quote userid="72692" url="~/f/nordic-q-a/88494/nrf9160-dk---uart-big-picture/372333#372333"]Is this suficcient for you? Every time you need to change pins, you reboot?[/quote]
&lt;p&gt;Well, yes and no. Of cause it would be more comfortable to re-configure the HW Peripherals without having to reboot the chip because &amp;quot;state&amp;quot; could be handled much easier this way. However, I understand why it is not possible at the moment and nonetheless, it is very good to know how the task can be tackled using either the reboot or the &amp;quot;direct-nrfx-driver&amp;quot; approach. Now it is up to us to discuss which route to take.&lt;/p&gt;
&lt;p&gt;Long story short, I believe I have all the information I was asking for (and more). Thus, many thanks to both of you for your support!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 DK - UART big picture</title><link>https://devzone.nordicsemi.com/thread/372333?ContentTypeID=1</link><pubDate>Tue, 14 Jun 2022 09:21:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:05fa817a-daf2-4f7c-8264-db9fc0fd3b03</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;What pin control enabled was to be able to reconfigure pins without needing to rebuild the app. However, you will need to reset the chip in order to change the configuration*. Is this suficcient for you? Every time you need to change pins, you reboot?&lt;/p&gt;
&lt;p&gt;If this is not sufficient, you could use the nrfx drivers directly, which gives you more control. However, then you loose the advantages and simplicity Zephyr brings with it. Here is a sample demonstrating how to use the nrfx drivers:&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/tree/v3.0.99-ncs1/samples/boards/nrf/nrfx"&gt;https://github.com/nrfconnect/sdk-zephyr/tree/v3.0.99-ncs1/samples/boards/nrf/nrfx&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;*The reason you need to reset your chip, is because the reconfiguration needs to happen before the pins gets initialized. For example for UART, the function &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.0.99-ncs1/drivers/serial/uart_nrfx_uarte.c#L1791"&gt;uart_nrfx_uarte.c--&amp;gt;&lt;span&gt;uarte_instance_init()&lt;/span&gt;&lt;/a&gt; will run at boot (before main), and will use the pins set by the &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.0.99-ncs1/drivers/serial/uart_nrfx_uarte.c#L2068-L2077"&gt;UART_NRF_UART_DEVICE macro&lt;/a&gt;&amp;nbsp;(which gets the pins from the device tree using &lt;span&gt;DT_PROP(_OR)&lt;/span&gt;). By using &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/kernel/drivers/index.html#system-drivers"&gt;SYS_INIT&lt;/a&gt;, you can run stuff at boot before the initialization functions, and this is what the dynamic_pinctrl sample does:&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.0.99-ncs1/samples/boards/nrf/dynamic_pinctrl/src/remap.c#L61"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/v3.0.99-ncs1/samples/boards/nrf/dynamic_pinctrl/src/remap.c#L61&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 DK - UART big picture</title><link>https://devzone.nordicsemi.com/thread/372264?ContentTypeID=1</link><pubDate>Tue, 14 Jun 2022 06:23:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:050132e8-2e85-4b99-9bd8-4c8d9323d1d5</guid><dc:creator>Sebastian Stein</dc:creator><description>&lt;p&gt;Hi Simon,&lt;/p&gt;
&lt;p&gt;thank you for your answer. The documentation you pointed at looks promising. However,&lt;/p&gt;
[quote userid="81181" url="~/f/nordic-q-a/88494/nrf9160-dk---uart-big-picture/370744#370744"]However, it is possible to re-configure them at runtime. So, e.g. assuming you don&amp;#39;t need the SPI and the I2C at the same time, you can use the same peripheral for both (with different pins, or some switching mechanism).[/quote]
&lt;p&gt;I am looking for a mechanism to re-configure (periodically back and forth) the HW peripherals at later stages during runtime (sorry if I was not clear about that). The description of the&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/tree/v3.0.99-ncs1/samples/boards/nrf/dynamic_pinctrl"&gt;dynamic_pinctrl sample&lt;/a&gt; makes the following two statements:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&amp;quot;&lt;em&gt;The Dynamic Pin Control (nRF) sample demonstrates how to change &lt;code&gt;uart0&lt;/code&gt; at early boot stages, [...]&lt;/em&gt;&amp;quot;&lt;/p&gt;
&lt;p&gt;&amp;quot;&lt;em&gt;Alternative configurations can only be applied if the device driver using the associated pins has not been initialized yet.&lt;/em&gt;&amp;quot;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I interpret these statements as if re-configuring HW peripherals is only possible during very early stages during the system startup and not during the &amp;quot;mode of operation&amp;quot; later on.&lt;/p&gt;
&lt;p&gt;Is it possible to re-configuring HW peripherals dynamically multiple times at runtime after boot and initialization? If yes, could you please explain to me how that can be done or point at the corresponding documentation?&lt;/p&gt;
&lt;p&gt;Thank you allot for your help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 DK - UART big picture</title><link>https://devzone.nordicsemi.com/thread/372223?ContentTypeID=1</link><pubDate>Mon, 13 Jun 2022 20:51:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5ff5067e-b6b5-4a55-8c51-02dc67436c7a</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Re-configuring pins of a peripheral in runtime is possible in NCS v2.0.0 with the introduction of &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.0.0/nrf/ug_pinctrl.html#pin-control"&gt;Pin control&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The sample dynamic_pinctrl demonstrates&amp;nbsp;how to do this:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.0.0/zephyr/samples/boards/nrf/dynamic_pinctrl/README.html"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.0.0/zephyr/samples/boards/nrf/dynamic_pinctrl/README.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/tree/v3.0.99-ncs1/samples/boards/nrf/dynamic_pinctrl"&gt;https://github.com/nrfconnect/sdk-zephyr/tree/v3.0.99-ncs1/samples/boards/nrf/dynamic_pinctrl&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Read more about dynamic pin control in the Zephyr documentation:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.0.0/zephyr/hardware/pinctrl/index.html#dynamic-pin-control"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.0.0/zephyr/hardware/pinctrl/index.html#dynamic-pin-control&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 DK - UART big picture</title><link>https://devzone.nordicsemi.com/thread/372006?ContentTypeID=1</link><pubDate>Mon, 13 Jun 2022 06:00:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3b7e0a3b-5941-4da6-87d8-729c2be3dfa0</guid><dc:creator>Sebastian Stein</dc:creator><description>&lt;p&gt;Hi Didrik,&lt;/p&gt;
&lt;p&gt;thank you for your Reply.&lt;/p&gt;
[quote userid="81181" url="~/f/nordic-q-a/88494/nrf9160-dk---uart-big-picture/370744#370744"]However, it is possible to re-configure them at runtime.[/quote]
&lt;p&gt;That sounds like a good solution to me. Can you please provide a link to the documentation of this feature or tell me in which header the corresponding functions are declared?&lt;/p&gt;
&lt;p&gt;Thank you!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 DK - UART big picture</title><link>https://devzone.nordicsemi.com/thread/370744?ContentTypeID=1</link><pubDate>Thu, 02 Jun 2022 15:23:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:822ede7a-d1e8-467f-b0d6-af1b9a4b1b14</guid><dc:creator>Didrik Rokhaug</dc:creator><description>&lt;p&gt;Correct. The nRF9160 only has 4 serial peripherals.&lt;/p&gt;
&lt;p&gt;However, it is possible to re-configure them at runtime. So, e.g. assuming you don&amp;#39;t need the SPI and the I2C at the same time, you can use the same peripheral for both (with different pins, or some switching mechanism).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 DK - UART big picture</title><link>https://devzone.nordicsemi.com/thread/370490?ContentTypeID=1</link><pubDate>Wed, 01 Jun 2022 14:15:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5faae8df-7f76-45fc-a768-d3de70f9f563</guid><dc:creator>Sebastian Stein</dc:creator><description>&lt;p&gt;Hi Didrik,&lt;/p&gt;
&lt;p&gt;thank you allot for you comprehensive answer. It clarified allot of things. I&amp;#39;ll make sure to have a look at the course you suggested.&lt;/p&gt;
[quote userid="81181" url="~/f/nordic-q-a/88494/nrf9160-dk---uart-big-picture/370459#370459"]We use the same HW peripheral for all serial busses: UART, SPI and I2C. The peripheral can only be one of those at a time.[/quote]
&lt;p&gt;If I interpret your statement and the device tree files correct, I have four and only four HW peripherals at my disposal when working with the nRF9160 DK. That means for example if I would use three of them as UARTs and one of them as SPI interface, I would be in trouble if I would need an additional I2C interface. Is that correct?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 DK - UART big picture</title><link>https://devzone.nordicsemi.com/thread/370459?ContentTypeID=1</link><pubDate>Wed, 01 Jun 2022 13:13:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:720aef27-ed89-4c6a-81da-cd69040caca9</guid><dc:creator>Didrik Rokhaug</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""]How do the different UART entities UART_9160_[0,1,2,3], UART_52840_[0,1], and UART_DK_[0,1,2] relate to each other?[/quote]
&lt;p&gt;&amp;nbsp;As you say, the nRF9160 can have 4 UARTs (UART_NRF9160_[0,1,2,3]), while the nRF52840 can have 2 UARTs (UART_NRF52840_[0,1]). We use the same HW peripheral for all serial busses: UART, SPI and I2C. The peripheral can only be one of those at a time. So, depending on your configuration, you might not have 4 UARTs available, but e.g. 2 UARTs, 1 I2C and 1 SPI. For simplicity going forward, let&amp;#39;s assume we always have the maximum possible amount of UARTs, unless explicitly stated otherwise.&lt;/p&gt;
&lt;p&gt;Which pins are assigned to which peripheral is configurable at runtime. In NCS and Zephyr, that configuration is done by the device tree files. So the pins you see in the SoC .dts files are simply the &amp;quot;default&amp;quot; pins used by the SDK, but they can be changed by boards and applications.&lt;/p&gt;
&lt;p&gt;When you look at ncs\v1.9.1\zephyr\boards\arm\nrf9160dk_nrf9160\nrf9160dk_nrf9160_common.dts, you see the configuration of the nRF9160 on the nRF9160 DK. Note that in the SoC board files, all the UARTs are disabled. In the DK board files, two of them are enabled, and the pins of the third are modified.&lt;/p&gt;
&lt;p&gt;In other words, UART_DK_[0,1,2] = UART_NRF9160_[0,1,2]. UART_NRF9160_3 are not mentioned in the DK board files. I.e. it uses the same pins as in the SoC files, and is still disabled.&lt;/p&gt;
&lt;p&gt;Again, I want to repeat that the both the board and SoC configurations can be overwritten by the application.&lt;/p&gt;
&lt;p&gt;The story for the nRF52840 is similar. In the SoC device tree files both UARTs are disabled, while in the board files (zephyr/boards/arm/nrf9160dk_nrf52840.dts) UART_NRF52840_0 is enabled, and the pinout is changed.&lt;/p&gt;
&lt;p&gt;In either case, these .dts files only tell you which UARTs has been routed to which pins of the SoCs. Not where those pins are routed on the actual DK.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user=""]Why does the nRF9160 DK only expose three UART entities while the nRF9160 has four?[/quote]
&lt;p&gt;If you are talking about UART_DK_[0,1,2], that is not the correct interpretation. See above.&lt;/p&gt;
&lt;p&gt;However, you are correct that the nRF9160 DK only converts 3 UARTs to virtual serial ports that you can see on your computer. This is because the on-board debugger only can convert&amp;nbsp; 3 UARTs to USB veirtula serial ports (VCOMs). Of these three UARTs, two are used by the nRF9160 (UART_NRF9160_0 and UART_NRF9160_1 by default), and one by the nRF52840 (UART_NRF52840_0 by default).&lt;/p&gt;
[quote user=""]How can I configure which UART entity is exposed through which pins of the nRF9160 DK[/quote]
&lt;p&gt;To better understand how to use the device tree, I recommend you our nRF Connect SDK Fundamentals course on our Nordic Developer Academy: &lt;a href="https://academy.nordicsemi.com/courses/nrf-connect-sdk-fundamentals/"&gt;https://academy.nordicsemi.com/courses/nrf-connect-sdk-fundamentals/&lt;/a&gt;&lt;/p&gt;
[quote user=""]Which UART entities are forwarded per default through the virtual comports?[/quote]
&lt;p&gt;See my answer above, as well as the &lt;a href="https://www.nordicsemi.com/Products/Development-hardware/nRF9160-DK/Download?lang=en#infotabs"&gt;schematics &lt;/a&gt;and &lt;a href="https://infocenter.nordicsemi.com/topic/ug_nrf91_dk/UG/nrf91_DK/intro.html"&gt;documentation &lt;/a&gt;for the DK.&lt;/p&gt;
[quote user=""]How can I configure which UART entities are forwarded through the virtual comports?[/quote]
&lt;p&gt;As previously mentioned, you can change the pinout so that the UART entity you want use the pins connected to the on-board debugger.&lt;/p&gt;
[quote user=""]How can I stop an UART entity from being forwarded&amp;nbsp; through the virtual comports?[/quote]
&lt;p&gt;You can either not use the pins connected to the on-board debugger, or you can change the routing on the DK so those pins are routed to the pin headers instead. For more information, see the board controller FW documentation: &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/zephyr/boards/arm/nrf9160dk_nrf52840/doc/index.html#board-controller-firmware"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/zephyr/boards/arm/nrf9160dk_nrf52840/doc/index.html#board-controller-firmware&lt;/a&gt;&lt;/p&gt;
[quote user=""]Assuming that UART_DK_0 is the &amp;quot;primary&amp;quot; UART used for console and AT data traffic, would it mess with the nRF9160 DK if UART_DK_0 would additionally be used to communicate to other external devices?[/quote]
&lt;p&gt;UART is only designed to be used between two nodes. Adding a third device is not really supported. However, you can use other UARTs for console and/or AT commands, or you can not use the console/AT commands at all.&lt;/p&gt;
[quote user=""]I would like to use the UARTs of the nRF9160 DK in the following way:[/quote]
&lt;p&gt;This should be easily enough with a device tree overlay file. I recommend staying with UART_NRF9160_0 for communicating over a VCOM, as well as having UART_NRF9160_1 for modem tracing. Modem traces are really an invaluable tool for debugging network and connection issues.&lt;/p&gt;
&lt;p&gt;The two UARTs for sensor communication can be UART_NRF9160_[2,3]. Just remember to disable I2C 2 and 3 and SPI 2 and 3.&lt;/p&gt;
&lt;p&gt;All that, as well as choosing which pins are used can be done in a device tree overlay file. As for which pins to use, you should look at the DK schematics.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Didrik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>