<?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 use UART pins as GPIO instead</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/91129/how-to-use-uart-pins-as-gpio-instead</link><description>I&amp;#39;m relatively new to both nRF and Zephyr platforms and I&amp;#39;m wondering how to disable UART on the UART pins (such as p0.19-p0.22 on the nRF5340 that I&amp;#39;m using) so that they can be used for simple digital output. I&amp;#39;ve been looking around and nothing that</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 22 Aug 2022 11:20:34 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/91129/how-to-use-uart-pins-as-gpio-instead" /><item><title>RE: How to use UART pins as GPIO instead</title><link>https://devzone.nordicsemi.com/thread/382650?ContentTypeID=1</link><pubDate>Mon, 22 Aug 2022 11:20:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ffff6c0-23fc-4ecd-9d02-435b619a13a3</guid><dc:creator>Michal</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;The debug SWD interface is connected to other pins, so that&amp;#39;s fine. There are &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf5340/chapters/pin.html?cp=3_0_0_8_0"&gt;dedicated pins&lt;/a&gt; for that on the chip.&lt;/p&gt;
&lt;p&gt;It&amp;#39;s just that UART0 on the default pins is being redirected via the debugger chip, so that you can access it via a VCOM port on your PC.&lt;br /&gt;I think that you can still use Segger RTT for that instead.&lt;/p&gt;
&lt;p&gt;Your pinctrl overlay looks correct to me.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Michal&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use UART pins as GPIO instead</title><link>https://devzone.nordicsemi.com/thread/382509?ContentTypeID=1</link><pubDate>Fri, 19 Aug 2022 18:03:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e985912e-a2d8-44aa-a795-f6b5bc70b049</guid><dc:creator>faskr</dc:creator><description>&lt;p&gt;Thanks for the reply. I am using NCS v2.0.2. Would I still be able to prototype using the debug SWD interface while UART pins are disabled? Alternatively, can the J-Link use UART1? I would also be interested in how to change the UART0 pins, which might be useful on the design I&amp;#39;m working on. Would it be something like this (based on nrf5340_cpuapp_common-pinctrl.dtsi)?&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;pinctrl {
	uart0_default: uart0_default {
		group1 {
			psels = &amp;lt;NRF_PSEL(UART_TX, 0, new_tx)&amp;gt;,
				&amp;lt;NRF_PSEL(UART_RTS, 0, new_rts)&amp;gt;;
		};
		group2 {
			psels = &amp;lt;NRF_PSEL(UART_RX, 0, new_rx)&amp;gt;,
				&amp;lt;NRF_PSEL(UART_CTS, 0, new_cts)&amp;gt;;
			bias-pull-up;
		};
	};

	uart0_sleep: uart0_sleep {
		group1 {
			psels = &amp;lt;NRF_PSEL(UART_TX, 0, new_tx)&amp;gt;,
				&amp;lt;NRF_PSEL(UART_RX, 0, new_rts)&amp;gt;,
				&amp;lt;NRF_PSEL(UART_RTS, 0, new_rts)&amp;gt;,
				&amp;lt;NRF_PSEL(UART_CTS, 0, new_cts)&amp;gt;;
			low-power-enable;
		};
	};
};&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use UART pins as GPIO instead</title><link>https://devzone.nordicsemi.com/thread/382500?ContentTypeID=1</link><pubDate>Fri, 19 Aug 2022 15:44:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c76812b7-11aa-4830-9dae-027086dbe03f</guid><dc:creator>Michal</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;My first question is: are you really sure that you want to do this? If you are using the development kit, those pins are connected to the onboard J-Link debugger (also called interface MCU in the documentation). You will possibly have to prototype without a debugger connected most of the time (there is a switch for that on the DK). It is also important to state your NCS version, since there were some big changes in 2.0.0 with the introduction of the &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.0.2/zephyr/hardware/pinctrl/index.html#pinctrl-guide"&gt;pinctrl API&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The second question is: do you want to completely turn off the UART0, or just change the pins that it uses? Because you can (almost) freely change the pins for this peripheral. I will assume the former for this reply, but please tell me if that is not the case.&lt;/p&gt;
&lt;p&gt;Otherwise, it&amp;#39;s a case of adding a devicetree overlay file. Since you are relatively new to the whole platform you may want to go through at least some part of our &lt;a href="https://academy.nordicsemi.com/courses/nrf-connect-sdk-fundamentals/"&gt;DevAcademy course&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://academy.nordicsemi.com/lessons/lesson-2-reading-buttons-and-controlling-leds/"&gt;Lesson 2&lt;/a&gt; is about devicetree and setting up and controlling GPIO pins, while &lt;a href="https://academy.nordicsemi.com/lessons/lesson-3-elements-of-an-nrf-connect-sdk-application/"&gt;lesson 3&lt;/a&gt; has information about the devicetree overlay and configuration files.&lt;/p&gt;
&lt;p&gt;We also have &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.0.2/zephyr/build/dts/index.html"&gt;a whole chapter/guide about devicetree in the Zephyr documentation&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I understand that it is a lot, so I am also going to show you a pretty simple example.&lt;/p&gt;
&lt;p&gt;The overlay file beneath is based on the following file: &lt;code&gt;zephyr/boards/arm/nrf5340dk_nrf5340/nrf5340_cpuapp_common.dts&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The rest of the answer is in the comments in the code.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;// Turn off UART0 completely to free the pins
&amp;amp;uart0 {
    status = &amp;quot;disabled&amp;quot;;
};

// &amp;quot;/&amp;quot; slash means the root node
/ {
    my_gpios {
        compatible = &amp;quot;gpio-leds&amp;quot;;
        my_gpio0: my_gpio_0 {
            gpios = &amp;lt; &amp;amp;gpio0 19 GPIO_PUSH_PULL&amp;gt;;
            label = &amp;quot;My GPIO 0&amp;quot;;
        };
        my_gpio1: my_gpio_1 {
            gpios = &amp;lt; &amp;amp;gpio0 20 GPIO_PUSH_PULL&amp;gt;;
            label = &amp;quot;My GPIO 1&amp;quot;;
        };
    };

    aliases {
        my-gpio0 = &amp;amp;my_gpio0;
        my-gpio1 = &amp;amp;my_gpio1;
    };

    // only add this if you want to use another UART instance for all the zephyr messages etc.
    // if you want to not use UART at all, remember to add CONFIG_SERIAL=N to the prj.conf
    chosen {
		zephyr,console = &amp;amp;uart1;
		zephyr,shell-uart = &amp;amp;uart1;
		zephyr,uart-mcumgr = &amp;amp;uart1;
		zephyr,bt-mon-uart = &amp;amp;uart1;
		zephyr,bt-c2h-uart = &amp;amp;uart1;
	};
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Michal&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>