<?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>Issue with Configuring GPIO P1.XX on nRF52</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/111889/issue-with-configuring-gpio-p1-xx-on-nrf52</link><description>Problem Description: I am trying to configure and control an LED connected to pin P1.07 on my nRF52 device, but I am experiencing issues. When I configure pin P1.07 as an output, I am unable to turn the LED on and off. However, if I use a pin on port</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 17 Jun 2024 09:40:45 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/111889/issue-with-configuring-gpio-p1-xx-on-nrf52" /><item><title>RE: Issue with Configuring GPIO P1.XX on nRF52</title><link>https://devzone.nordicsemi.com/thread/489046?ContentTypeID=1</link><pubDate>Mon, 17 Jun 2024 09:40:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f0f7fbcd-dce9-4d46-8d67-4acc06b9aff6</guid><dc:creator>Priyanka</dc:creator><description>&lt;p&gt;That&amp;#39;s great. Happy to hear that the issue is resolved. Closing the ticket. &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;-Priyanka&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issue with Configuring GPIO P1.XX on nRF52</title><link>https://devzone.nordicsemi.com/thread/489020?ContentTypeID=1</link><pubDate>Mon, 17 Jun 2024 08:17:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:95a982cd-2d7a-440d-aef3-0d1f1c641544</guid><dc:creator>GC92ES</dc:creator><description>&lt;p&gt;Thank you for your responses and sorry for the delay in getting back to you. I&amp;#39;ve had a few hectic days at work, but I wanted to share that I found a solution to my problem.&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s the working code (example):&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/* Define the LED node */
#define LED_NODE DT_NODELABEL(led_green)
static struct gpio_dt_spec led = GPIO_DT_SPEC_GET_OR(LED_NODE, gpios, {1});

/* Function to configure the LEDs */
int configure_leds(void)
{
    int ret;

    /* Check if the LED device is ready */
    if (!gpio_is_ready_dt(&amp;amp;led))
    {
        printk(&amp;quot;Error %d: LED device %s is not ready; ignoring it\n&amp;quot;, ret, led.port-&amp;gt;name);
        return -1;
    }

    /* Configure the LED pin as output */
    ret = gpio_pin_configure_dt(&amp;amp;led, GPIO_OUTPUT);
    if (ret != 0)
    {
        printk(&amp;quot;Error %d: failed to configure pin %d on LED device %s\n&amp;quot;, ret, led.pin, led.port-&amp;gt;name);
        return ret;
    }

    return 0;
}

void main(void)
{
    int ret;

    /* Initialize the LEDs */
    ret = configure_leds();
    if (ret != 0)
    {
        printk(&amp;quot;Failed to configure LEDs\n&amp;quot;);
        return;
    }

    /* Main loop */
    while (1)
    {
        /* Toggle the LED state */
        gpio_pin_toggle_dt(&amp;amp;led);
        k_sleep(K_MSEC(1000));  // Sleep for 1 second
    }
}

/* Additional commands to turn the LED on and off */
gpio_pin_set_dt(&amp;amp;led, 1); // LED on
gpio_pin_set_dt(&amp;amp;led, 0); // LED off&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;This solution works for both GPIO0 and GPIO1.&lt;/p&gt;
&lt;p&gt;Thank you again for your assistance!&lt;/p&gt;
&lt;p&gt;Best regards.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issue with Configuring GPIO P1.XX on nRF52</title><link>https://devzone.nordicsemi.com/thread/488225?ContentTypeID=1</link><pubDate>Tue, 11 Jun 2024 07:10:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6edb66b8-885c-4205-a9b3-ad7b79ea3246</guid><dc:creator>Priyanka</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Yes, it&amp;#39;s true that the configuration of GPIO1 port pins might not be as straightforward as those of GPIO0. This is because the buttons and LEDs are usually connected to the same GPIO port in&amp;nbsp;our official DKs. If the buttons are connected to a different GPIO port (e.g., GPIO_1) than the LEDs, a new device driver binding or device pointer is required. Please take a look at this:&amp;nbsp;&lt;a href="https://academy.nordicsemi.com/courses/nrf-connect-sdk-fundamentals/lessons/lesson-2-reading-buttons-and-controlling-leds/topic/exercise-1-2/"&gt;https://academy.nordicsemi.com/courses/nrf-connect-sdk-fundamentals/lessons/lesson-2-reading-buttons-and-controlling-leds/topic/exercise-1-2/&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In the &lt;em&gt;dk_buttons_and_leds&lt;/em&gt; file, you might need to make some modifications to properly configure the GPIO1 port pins. For instance, you might need to define a new device pointer for the GPIO1 port and use it to initialize and configure the GPIO1 port pins. Please take a look at this thread:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/92870/how-to-link-nrfx_gpiote-and-gpio1-port-on-zephyr?ReplyFilter=Answers&amp;amp;ReplySortBy=Answers&amp;amp;ReplySortOrder=Descending"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/92870/how-to-link-nrfx_gpiote-and-gpio1-port-on-zephyr?ReplyFilter=Answers&amp;amp;ReplySortBy=Answers&amp;amp;ReplySortOrder=Descending&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;-Priyanka&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issue with Configuring GPIO P1.XX on nRF52</title><link>https://devzone.nordicsemi.com/thread/488032?ContentTypeID=1</link><pubDate>Mon, 10 Jun 2024 07:45:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:559b5784-5f5a-4e19-a04b-042e8eb2c643</guid><dc:creator>GC92ES</dc:creator><description>&lt;p&gt;Hi Priyanka,&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Please make sure that the P1.07 is not being used by any other peripherals etc.&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Not used, the board is custom so there should be no problem.&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ol start="2"&gt;
&lt;li&gt;Is your LED properly connected to the P1.07? Maybe try changing to another pin on the same port to rule out any hardware issues with P1.07?&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;The LED is connected with the ground to GND and the positive to the pin.&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ol start="3"&gt;
&lt;li&gt;You mention that when connecting to P0.07 the LED lights up. Do you use the same LED? Just to rule out that it might be an LED issue.&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;The LED is the same, yes, I just changed the port from zero to one.&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I have tried other solutions and this seems to work, the problem is that it seems to work for the LEDs but not for the GPIOs. Do I need to use other settings or should these be the correct ones?&lt;br /&gt;&lt;br /&gt;I read somewhere that the pins of the GPIO1 port are not configurable in the same way as those of GPIO0. I wanted to understand if this is true. In my project, I was using the &lt;code&gt;dk_buttons_and_leds&lt;/code&gt; file to manage LEDs and buttons. I don&amp;#39;t think it works properly, or is it enough to make some modifications to the file?&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;lt;hal/nrf_gpio.h&amp;gt; // Include if using nRF specific features
// #define LED_BATTERY_75_100 NRF_GPIO_PIN_MAP(0, 17)
#define LED_BATTERY_75_100 NRF_GPIO_PIN_MAP(1, 17)

/* -------------------------------------------------------------------------- */
/*                                     LED                                    */
/* -------------------------------------------------------------------------- */

void TurnLEDOn(uint32_t led_pin)
{
    // nrf_gpio_cfg_output(led_pin);
    nrf_gpio_pin_clear(led_pin);
}

void TurnLEDOff(uint32_t led_pin)
{
    // nrf_gpio_cfg_output(led_pin);
    nrf_gpio_pin_set(led_pin);
}

void WriteLEDState(uint32_t led_pin, uint32_t state)
{
    nrf_gpio_pin_write(led_pin, state);
}

void ToggleLED(uint32_t led_pin)
{
    nrf_gpio_cfg_output(led_pin);
    uint32_t state = nrf_gpio_pin_out_read(led_pin);
    if (state == 0)
    {
        nrf_gpio_pin_set(led_pin);
    }
    else
    {
        nrf_gpio_pin_clear(led_pin);
    }
}

/* -------------------------------------------------------------------------- */
/*                                    MAIN                                    */
/* -------------------------------------------------------------------------- */

void configure_gpio(void)
{
    // Configure GPIOs used by the application
}

void main(void)
{
    configure_gpio(); // Configure the GPIOs used by the application
    nrf_gpio_cfg_output(LED_BATTERY_75_100);

    while (1)
    {
        TurnLEDOff(LED_BATTERY_75_100);
        k_sleep(K_MSEC(500));
        TurnLEDOn(LED_BATTERY_75_100);
        k_sleep(K_MSEC(500)); // Wait for 500 ms
    }
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Thanks for your response.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issue with Configuring GPIO P1.XX on nRF52</title><link>https://devzone.nordicsemi.com/thread/488024?ContentTypeID=1</link><pubDate>Mon, 10 Jun 2024 07:24:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:41eafbc2-5e06-436c-ad8f-f1aedd3f865b</guid><dc:creator>Priyanka</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;You configuration seems correct. Could you confirm the following too?&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;1. Please make sure that the P1.07 is not being used by any other peripherals etc.&lt;/p&gt;
&lt;p&gt;2. Is your LED properly connected to the P1.07? Maybe try changing to another pin on the same port to rule out any hardware issues with P1.07?&lt;/p&gt;
&lt;p&gt;3. You mention that when connecting to P0.07 the LED lights u. Do you use the same LED? Just to rule out that it might be an LED issue.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Priyanka&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>