<?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>Using a pin both as a GPIO and as a PWM pin. The device tree and the overlay hell.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/107994/using-a-pin-both-as-a-gpio-and-as-a-pwm-pin-the-device-tree-and-the-overlay-hell</link><description>Hi, we started using nRFConnect SDK a few month ago and we are still having tough time every time we need to implement some configuration not directly available inside some example. 
 We believe it is mostly our fault because lack of knowledge, anyway</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 12 Feb 2024 14:35:22 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/107994/using-a-pin-both-as-a-gpio-and-as-a-pwm-pin-the-device-tree-and-the-overlay-hell" /><item><title>RE: Using a pin both as a GPIO and as a PWM pin. The device tree and the overlay hell.</title><link>https://devzone.nordicsemi.com/thread/468426?ContentTypeID=1</link><pubDate>Mon, 12 Feb 2024 14:35:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ffb6ee63-a5f3-4eeb-aedc-fd9aba51118a</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;So I took the time to implement something like you suggest. Please have a look at the attached application (tested in ncs v2.5.1):&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/hello_5F00_world_5F00_pwm_5F00_gpio_5F00_input.zip"&gt;devzone.nordicsemi.com/.../hello_5F00_world_5F00_pwm_5F00_gpio_5F00_input.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;To test on an nRF52840dk, please short P0.11 (button1) and P0.13 (LED1). The way it works is that it starts with 1 second of toggling the LED as a PWM signal. Then it switches over to gpio input on the LED pin. I set up a new button (or switch, really) in nrf52840dk_nrf52840.overlay on P0.13. You can ground the P0.13 directly, but it is easier to test if you short it to button 1 and press the button. The log should let you know when the button is pressed (when the GPIO is in interrupt mode).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using a pin both as a GPIO and as a PWM pin. The device tree and the overlay hell.</title><link>https://devzone.nordicsemi.com/thread/467996?ContentTypeID=1</link><pubDate>Thu, 08 Feb 2024 06:08:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5fc0c28d-ea9b-47a3-80d3-b979ea7408c3</guid><dc:creator>knutel</dc:creator><description>&lt;p&gt;Maybe this answer will help you? They have 3 PWM channels set up successfully, it seems: &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/95405/adding-pwm-channels-in-zephyr"&gt;devzone.nordicsemi.com/.../adding-pwm-channels-in-zephyr&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Knut&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using a pin both as a GPIO and as a PWM pin. The device tree and the overlay hell.</title><link>https://devzone.nordicsemi.com/thread/467620?ContentTypeID=1</link><pubDate>Mon, 05 Feb 2024 15:19:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3bdf9600-4a06-4d25-b8ba-e24409e2231e</guid><dc:creator>DavideDN</dc:creator><description>&lt;p&gt;Thank you for the example, but this is not helping me regarding the configuration.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Do you have any hint on how to define all the required device trees and overlay files?&lt;br /&gt;We have no idea on how to define that we wish to control 4 leds using the four channels inside PWM0 peripheral.&lt;/p&gt;
&lt;p&gt;br&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Davide&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using a pin both as a GPIO and as a PWM pin. The device tree and the overlay hell.</title><link>https://devzone.nordicsemi.com/thread/467609?ContentTypeID=1</link><pubDate>Mon, 05 Feb 2024 14:50:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0b6eac3c-1ffd-4ab7-8d99-ceca5a5ab82d</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello DDN,&lt;/p&gt;
&lt;p&gt;Sorry for the late reply.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;While it is a bit tedious to use one GPIO for two different peripherals in NCS, it should be possible to use it for a peripheral and as a normal GPIO, just by disabling the peripheral.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;A colleague of mine just did something similar (except for with UART and GPIO output). Please have a look, and see if this is something you can use. Let me know if you have difficulties translating this to PWM.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you short the P0.06 with P0.13, you should see that you are able to see the UART output (using P0.06 for UART TX), and then the LED will toggle (because P0.06 is shorted to P0.13, which is the LED1 pin).&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/hello_5F00_world_5F00_toggle_5F00_uart_5F00_onoff.zip"&gt;devzone.nordicsemi.com/.../hello_5F00_world_5F00_toggle_5F00_uart_5F00_onoff.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using a pin both as a GPIO and as a PWM pin. The device tree and the overlay hell.</title><link>https://devzone.nordicsemi.com/thread/467322?ContentTypeID=1</link><pubDate>Fri, 02 Feb 2024 09:45:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e19d0cec-76dd-4e73-9e5c-f1547cb67dde</guid><dc:creator>DavideDN</dc:creator><description>&lt;p&gt;I am adding a few lines here to avoid receiving an miscentered or off topic answer.&lt;/p&gt;
&lt;p&gt;Of course one can &amp;quot;emulate&amp;quot; a GPIO ON state with a PWM 100% setting and OFF with 0%: but the point is not this one.&lt;/p&gt;
&lt;p&gt;May be I should have asked to use the same pin with both PWM (out) functionality and as a GPIO input (not at the same time obviously)&lt;/p&gt;
&lt;p&gt;So what would be a very valuable hint is: an example of the correct board overly to achieve this, along with a sample code snippet to programmatically switch among PWM and GPIO pin function.&lt;/p&gt;
&lt;p&gt;Looking forward and best regards&lt;/p&gt;
&lt;p&gt;DDN&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>