<?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>nrf52840 dongle PCA10059 GPIO Out LED</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/118113/nrf52840-dongle-pca10059-gpio-out-led</link><description>I am trying to get an LED attached to GPIO to turn on. I have tried all documented methods I could find but with no success. I have no issue controlling the onboard LEDS but I cannot seem to configure a GPIO as an output. I also have no issue configuring</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 18 Jan 2025 20:21:09 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/118113/nrf52840-dongle-pca10059-gpio-out-led" /><item><title>RE: nrf52840 dongle PCA10059 GPIO Out LED</title><link>https://devzone.nordicsemi.com/thread/518951?ContentTypeID=1</link><pubDate>Sat, 18 Jan 2025 20:21:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0228bd44-540e-4503-9248-9a08e230de5c</guid><dc:creator>shaneelliott</dc:creator><description>&lt;p&gt;Not a pretty solution but this works.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void pinOn(uint32_t pin) {
    // Set pin direction as input using DIRCLR register
    NRF_GPIO-&amp;gt;DIRCLR = (1 &amp;lt;&amp;lt; pin);

    NRF_GPIO-&amp;gt;PIN_CNF[pin] = (NRF_GPIO_PIN_DIR_INPUT &amp;lt;&amp;lt; GPIO_PIN_CNF_DIR_Pos)
                               | (NRF_GPIO_PIN_INPUT_CONNECT &amp;lt;&amp;lt; GPIO_PIN_CNF_INPUT_Pos)
                               | (NRF_GPIO_PIN_PULLUP &amp;lt;&amp;lt; GPIO_PIN_CNF_PULL_Pos)
                               | (NRF_GPIO_PIN_S0S1 &amp;lt;&amp;lt; GPIO_PIN_CNF_DRIVE_Pos)
                               | (NRF_GPIO_PIN_NOSENSE &amp;lt;&amp;lt; GPIO_PIN_CNF_SENSE_Pos);
}

void clearPin(uint32_t pin) {
    // Reset PIN_CNF register to default value
    NRF_GPIO-&amp;gt;PIN_CNF[pin] = 0;  // All bits set to 0 (default state)
    
    // Clear direction (set as input - default state)
    NRF_GPIO-&amp;gt;DIRCLR = (1 &amp;lt;&amp;lt; pin);
    
    // Clear output value
    NRF_GPIO-&amp;gt;OUTCLR = (1 &amp;lt;&amp;lt; pin);
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52840 dongle PCA10059 GPIO Out LED</title><link>https://devzone.nordicsemi.com/thread/518870?ContentTypeID=1</link><pubDate>Fri, 17 Jan 2025 14:03:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:16019a41-a610-4dc7-b002-f12dc3aa7246</guid><dc:creator>shaneelliott</dc:creator><description>&lt;p&gt;I will try running the following&amp;nbsp;&lt;/p&gt;
&lt;p&gt;led_setup();&lt;br /&gt; led_on();&lt;br /&gt; nrf_delay_ms(1000); // Sleep/block for 1 second&lt;br /&gt; led_off();&lt;br /&gt; nrf_delay_ms(1000); // Sleep/block for 1 second&lt;br /&gt; led_on();&lt;/p&gt;
&lt;p&gt;but also just tried changing the pin map of the board LED in pca10059.h so basically its gets setup exactly the same as the onboard LED&amp;#39;s but this did not help&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52840 dongle PCA10059 GPIO Out LED</title><link>https://devzone.nordicsemi.com/thread/518868?ContentTypeID=1</link><pubDate>Fri, 17 Jan 2025 14:00:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6c2a494e-ea7a-41b2-92fc-7a73919325cd</guid><dc:creator>shaneelliott</dc:creator><description>&lt;p&gt;I unfortunately don&amp;#39;t have a debugger attached to nrf52840 dongle which problem solving pretty tricky&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52840 dongle PCA10059 GPIO Out LED</title><link>https://devzone.nordicsemi.com/thread/518865?ContentTypeID=1</link><pubDate>Fri, 17 Jan 2025 13:58:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:baea1da1-76c8-4e97-b811-675b2689a236</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;I don&amp;#39;t see any obvious issues here. Can you call your&amp;nbsp;led_on() and&amp;nbsp;led_off() function after&amp;nbsp;led_setup() in your main function and verify with a debugger that they actually run? If so, it should work. You can also step down into them when debugging to verify that it does and that the OUT register is set as it should (note that you should do this before initializing the SoftDevice, as that complicates debugging a bit).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52840 dongle PCA10059 GPIO Out LED</title><link>https://devzone.nordicsemi.com/thread/518863?ContentTypeID=1</link><pubDate>Fri, 17 Jan 2025 13:52:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dfa93751-dc3f-46a4-80b8-6a4f3150573f</guid><dc:creator>shaneelliott</dc:creator><description>&lt;p&gt;yes i have double checked the voltage output on the pin and get nothing. The led still looks good. Her is the full source code. LED is connected (0.9) in this&amp;nbsp;&lt;a title="nrf52840 project" href="https://drive.google.com/file/d/18iL3t57LD_V3lU2_xP-JLgGanAloNKDK/view?usp=sharing"&gt;https://drive.google.com/file/d/18iL3t57LD_V3lU2_xP-JLgGanAloNKDK/view?usp=sharing&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52840 dongle PCA10059 GPIO Out LED</title><link>https://devzone.nordicsemi.com/thread/518850?ContentTypeID=1</link><pubDate>Fri, 17 Jan 2025 13:18:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:97e668ee-389f-4b9a-9248-553788ecc272</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I see. This looks correct. Could it be that you are missing an include or similar - do you get warnings when building? Or can you share the full code?&lt;/p&gt;
&lt;p&gt;Also, if you have connected the LED to VDD for some time&amp;nbsp;without a series resistor (if I read you correctly) you may have damaged it, so it is worth checking if it still works. Perhaps just measure the voltage on P0.02 to verify if you get it set and cleared correctly?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52840 dongle PCA10059 GPIO Out LED</title><link>https://devzone.nordicsemi.com/thread/518849?ContentTypeID=1</link><pubDate>Fri, 17 Jan 2025 13:10:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d78c70e7-a2c0-4193-ba36-e43bf2ab8bbb</guid><dc:creator>shaneelliott</dc:creator><description>&lt;p&gt;yes that was the exact code i tried.&lt;/p&gt;
&lt;p&gt;#define LED_PIN NRF_GPIO_PIN_MAP(0,2)&lt;/p&gt;
&lt;p&gt;void led_setup(void)&lt;br /&gt;{&lt;br /&gt; ret_code_t err_code;&lt;/p&gt;
&lt;p&gt;// Configure the output pin&lt;br /&gt; nrf_gpio_cfg_output(LED_PIN);&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;void led_on(void) {&lt;br /&gt; nrf_gpio_pin_clear(&lt;span&gt;LED_PIN&lt;/span&gt;);&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;void led_off(void) {&lt;br /&gt; nrf_gpio_pin_set(&lt;span&gt;LED_PIN&lt;/span&gt;);&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;I am using SDK17.1.0. I have tried on other PINs as well. Also I am using a soft device in my main code but have tried with and without a soft device present&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52840 dongle PCA10059 GPIO Out LED</title><link>https://devzone.nordicsemi.com/thread/518843?ContentTypeID=1</link><pubDate>Fri, 17 Jan 2025 12:57:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9a0eee4f-98a4-4bd4-b718-2389957dbfd1</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Which method did you try, and which pin have you conneced the LED to? Also, which SDK are you using?&lt;/p&gt;
&lt;p&gt;The simplest way to control a GPIO (which control the LED) is to just set it directly using&amp;nbsp;&lt;code&gt;nrf_gpio_pin_set()&lt;/code&gt; and&amp;nbsp;&lt;code&gt;nrf_gpio_pin_clear()&lt;/code&gt; with the pin number as parameter. For that you need &amp;quot;&lt;code&gt;#include &amp;lt;hal/nrf_gpio.h&amp;gt;&lt;/code&gt;&amp;quot;, and you need to first configure the pin as output using&amp;nbsp;&lt;code&gt;nrf_gpio_cfg_output()&lt;/code&gt;, with the pin number as parameter here as well.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>