P1.00 doesn't work the way I expect on the nrf5340dk...

I can't see why P1.00 doesn't work the way I expect on the nrf5340dk...

This is just the blinky sample used to confirm my boards overlay file. Blinky works on all the pins except &led0(P1.00).

P1.00 seems to be unencumbered by any other peripheral so I'm not sure why this one doesn't work.

I am most interested in "where do I go to find out why something like this doesn't work". Or am I just missing something obvious?

This is what I was referencing:  https://infocenter.nordicsemi.com/index.jsp?topic=%2Fug_nrf5340_dk%2FUG%2Fdk%2Fintro.html

C:\nrf\blinky\boards\nrf5340dk_nrf5340_cpuapp.overlay

/ {
    aliases {
        led0 = &led0; //P1.00 doesn't work???
        led1 = &led1;
        led2 = &led2;
        led3 = &led3;
        led4 = &led4;
        led5 = &led5;
        led6 = &led6;
        led7 = &led7;
    };

    leds {
        compatible = "gpio-leds";
        led0: led_0 {
            gpios = <&gpio1 0 GPIO_ACTIVE_LOW>;
            label = "Green LED 0";
        };
        led1: led_1 {
            gpios = <&gpio1 1 GPIO_ACTIVE_LOW>;
            label = "Green LED 1";
        };
        led2: led_2 {
            gpios = <&gpio1 4 GPIO_ACTIVE_LOW>;
            label = "Green LED 2";
        };
        led3: led_3 {
            gpios = <&gpio1 5 GPIO_ACTIVE_LOW>;
            label = "Green LED 3";
        };
        led4: led_4 {
            gpios = <&gpio1 6 GPIO_ACTIVE_LOW>;
            label = "Green LED 6";
        };
        led5: led_5 {
            gpios = <&gpio1 7 GPIO_ACTIVE_LOW>;
            label = "Green LED 7";
        };
        led6: led_6 {
            gpios = <&gpio1 8 GPIO_ACTIVE_LOW>;
            label = "Green LED 8";
        };
        led7: led_7 {
            gpios = <&gpio1 9 GPIO_ACTIVE_LOW>;
            label = "Green LED 9";
        };
    };
};
/*
 * Copyright (c) 2016 Intel Corporation
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include <zephyr/kernel.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(main, LOG_LEVEL_INF);


/* 1000 msec = 1 sec */
#define SLEEP_TIME_MS   100

/* The devicetree node identifier for the "led0" alias. */
#define LED0_NODE DT_ALIAS(led0)
#define LED1_NODE DT_ALIAS(led1)
#define LED2_NODE DT_ALIAS(led2)
#define LED3_NODE DT_ALIAS(led3)
#define LED4_NODE DT_ALIAS(led4)
#define LED5_NODE DT_ALIAS(led5)
#define LED6_NODE DT_ALIAS(led6)
#define LED7_NODE DT_ALIAS(led7)

/*
 * A build error on this line means your board is unsupported.
 * See the sample documentation for information on how to fix this.
 */

const struct gpio_dt_spec sw[] = {
	GPIO_DT_SPEC_GET(LED0_NODE, gpios),
	GPIO_DT_SPEC_GET(LED1_NODE, gpios),
	GPIO_DT_SPEC_GET(LED2_NODE, gpios),
	GPIO_DT_SPEC_GET(LED3_NODE, gpios),
	GPIO_DT_SPEC_GET(LED4_NODE, gpios),
	GPIO_DT_SPEC_GET(LED5_NODE, gpios),
	GPIO_DT_SPEC_GET(LED6_NODE, gpios),
	GPIO_DT_SPEC_GET(LED7_NODE, gpios),
};

static int leds_init(void)
{
	int err;

	if (!device_is_ready(sw[0].port)) {
		LOG_ERR("LEDs port not ready");
		return -ENODEV;
	}

	for (size_t i = 0; i < ARRAY_SIZE(sw); i++) {

		printk("pin: Px.%d\n", sw[i].pin);

		err = gpio_pin_configure_dt(&sw[i], GPIO_OUTPUT_INACTIVE);

		if (err) {
			LOG_ERR("Unable to configure sw%u, err %d.", i, err);
			return err;
		}
	}

	return 0;
}

int main(void)
{
	int ret;

	if (!gpio_is_ready_dt(&sw[0])) {
		return 0;
	}

	leds_init();

	while (1) {
		for (uint8_t i = 0; i < ARRAY_SIZE(sw); i++)
		{
			ret = gpio_pin_toggle_dt(&sw[i]);

			if (ret < 0) {
				LOG_ERR("unable to toggle sw[%d]", i);
			}
		}
		
		k_msleep(SLEEP_TIME_MS);
	}
	return 0;
}
Parents
  • This pin is selected by uart1 in the 5340DK's pin control file. You could disable uart1 and/or change the pinctrl definitions for uart1.

    EDIT: to your second question, you could use our visual devicetree viewer or otherwise check the definitions under "zephyr/boards/arm/<YOUR_BOARD>" to see what pins are being used in pin control.

  • visual devicetree is a great idea I hadn't thought of... I checked and uart1 isn't enabled. If I follow the overlapping assignment link in my overlay file I come to: gpio_fwd: nrf-gpio-forwarder.

    I disabled that with the following. It removed the overlapping pin warning, but it didn't improve p1.00.

        gpio_fwd: nrf-gpio-forwarder {
            compatible = "nordic,nrf-gpio-forwarder";
            uart {
                status = "disabled";
                gpios = <&gpio1 1 0>, <&gpio1 0 0>, <&gpio0 11 0>, <&gpio0 10 0>;
            };
        };
    I enabled 8 gpio pins and they all work except for P1.00...
    	while (1) {
    		for (uint8_t i = 0; i < ARRAY_SIZE(sw); i++)
    		{
    			ret = gpio_pin_toggle_dt(&sw[i]);
    			LOG_INF("toggle &sw[i].pin: %d", sw[i].pin);
    
    			if (ret < 0) {
    				LOG_ERR("unable to toggle sw[%d]", i);
    			}
    		}
    		
    		k_msleep(SLEEP_TIME_MS);
    	}
    [00:00:04.260,955] <inf> main: toggle &sw[i].pin: 0
    [00:00:04.260,986] <inf> main: toggle &sw[i].pin: 1
    [00:00:04.261,016] <inf> main: toggle &sw[i].pin: 4
    [00:00:04.261,016] <inf> main: toggle &sw[i].pin: 5
    [00:00:04.261,047] <inf> main: toggle &sw[i].pin: 6
    [00:00:04.261,047] <inf> main: toggle &sw[i].pin: 7
    [00:00:04.261,077] <inf> main: toggle &sw[i].pin: 8
    [00:00:04.261,077] <inf> main: toggle &sw[i].pin: 9
Reply
  • visual devicetree is a great idea I hadn't thought of... I checked and uart1 isn't enabled. If I follow the overlapping assignment link in my overlay file I come to: gpio_fwd: nrf-gpio-forwarder.

    I disabled that with the following. It removed the overlapping pin warning, but it didn't improve p1.00.

        gpio_fwd: nrf-gpio-forwarder {
            compatible = "nordic,nrf-gpio-forwarder";
            uart {
                status = "disabled";
                gpios = <&gpio1 1 0>, <&gpio1 0 0>, <&gpio0 11 0>, <&gpio0 10 0>;
            };
        };
    I enabled 8 gpio pins and they all work except for P1.00...
    	while (1) {
    		for (uint8_t i = 0; i < ARRAY_SIZE(sw); i++)
    		{
    			ret = gpio_pin_toggle_dt(&sw[i]);
    			LOG_INF("toggle &sw[i].pin: %d", sw[i].pin);
    
    			if (ret < 0) {
    				LOG_ERR("unable to toggle sw[%d]", i);
    			}
    		}
    		
    		k_msleep(SLEEP_TIME_MS);
    	}
    [00:00:04.260,955] <inf> main: toggle &sw[i].pin: 0
    [00:00:04.260,986] <inf> main: toggle &sw[i].pin: 1
    [00:00:04.261,016] <inf> main: toggle &sw[i].pin: 4
    [00:00:04.261,016] <inf> main: toggle &sw[i].pin: 5
    [00:00:04.261,047] <inf> main: toggle &sw[i].pin: 6
    [00:00:04.261,047] <inf> main: toggle &sw[i].pin: 7
    [00:00:04.261,077] <inf> main: toggle &sw[i].pin: 8
    [00:00:04.261,077] <inf> main: toggle &sw[i].pin: 9
Children
No Data
Related