nRF5340 Audio DK: GPIO P0.07 Not Outputting High?

Hello, 

    I am trying to make GPIO P0.07 to high, in my nrf5340 Audio DK. Externally I am connecting an LED between P0.07 and GND. But it not showing any voltage between them. below is my code

#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/sys/printk.h>

static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(DT_ALIAS(newpin), testpin_gpios);

int main(void)
{
    int ret;

    if (!gpio_is_ready_dt(&led)) {
        printk("Error: LED device %s is not ready\n", led.port->name);
        return 0;
    }

    ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);
    if (ret < 0) {
        printk("Error %d: Failed to configure LED pin\n", ret);
        return 0;
    }

    printk("Setting GPIO HIGH on P0.07\n");

    /* Set GPIO HIGH */
    gpio_pin_set_dt(&led, 1);

    while (1) {
        k_sleep(K_FOREVER); // Keep running
    }
	return 0;
}

My overlay file is 

/ {
	testpin: zephyr,user {
		testpin-gpios = <&gpio0 7 0>;
	};

	aliases {
		newpin = &testpin;
	};
};

&gpio0 {
	status = "okay";
};

&gpiote {
	status = "okay";
};

my config file

CONFIG_PRINTK=y
CONFIG_PWM=y
CONFIG_GPIO=y
CONFIG_LOG=y
CONFIG_PWM_LOG_LEVEL_DBG=y

But the board's inbuilt red led is glowing. 

Parents
  • that is working fine, here also in built-in led is working. But if i connect an external led in P0.07 and GND it is not working

  • I tested with blinky example, I changed the pin in overlay file like below. I am not getting any voltage in GPIO pin P0.08. When configure it to P0.07 or P0.25 built-in Leds are flashing without issue.

    &rgb1_red {
    	gpios = <&gpio0 8 0>;
    };

  • Hello,

    So it is P0.07 you want to control, right?

    By default, this is connected to the red RGB led. Software wise, it is being controlled by PWM0, channel 0:

    (this is from NCS\zephyr\boards\nordic\nrf5340_audio_dk\nrf5340_audio_dk_nrf5340_cpuapp_common.dtsi)

    I have not tested this from the application, but you can try to add a file, nrf5340_audio_dk_nrf5340_cpuapp.overlay in your application's root folder (same folder as the CMakeLists.txt), and add the following line to it:

    /delete-node/ &pwm0;

    This will, however, disable the RGB leds on the Audio DK. 

    You would probably see, if you made your application set the color to red (without the line above), see that the voltage would be high.

    Best regards,

    Edvin

  • When i am adding "

    /delete-node/ &pwm0;" 

     

    /{
    	testpin: zephyr,user {
    		testpin-gpios = <&gpio0 7 0>;
    	};
    
    	aliases {
    		newpin = &testpin;
    	};
    };
    
    &gpio0 {
    	status = "okay";
    };
    
    &gpiote {
    	status = "okay";
    };
    
    /delete-node/ &pwm0;

    I am getting error "devicetree error: /pwmleds/pwm_led_0: undefined node label 'pwm0'"

  • Yes, you would need to remove all references to pwm0 in your application. It is probably easier to use another pin, instead of the P0.07.

    Or alternatively, instead of using /delete-node/, you could move the pin used for pwm_led_0, by adding this to your .overlay file:

    &pinctrl {
    	pwm0_default: pwm0_default {
    		group1 {
    			psels = <NRF_PSEL(PWM_OUT0, 0, 8)>,
    				<NRF_PSEL(PWM_OUT1, 0, 25)>,
    				<NRF_PSEL(PWM_OUT2, 0, 26)>;
    		};
    	};
    
    	pwm0_sleep: pwm0_sleep {
    		group1 {
    			psels = <NRF_PSEL(PWM_OUT0, 0, 8)>,
    				<NRF_PSEL(PWM_OUT1, 0, 25)>,
    				<NRF_PSEL(PWM_OUT2, 0, 26)>;
    			low-power-enable;
    		};
    	};
    };

    But note that P0.07 will still be physically connected to the LED on the Audio DK.

    Also note that I now moved the first PWM channel to pin P0.08, but you can move it to any pin you'd prefer, that is free.

    BR,

    Edvin

  • #include <zephyr/kernel.h>
    #include <zephyr/device.h>
    #include <zephyr/drivers/gpio.h>
    #include <zephyr/sys/printk.h>
    
    static const struct gpio_dt_spec spec = GPIO_DT_SPEC_GET(DT_ALIAS(newpin), testpin_gpios);
    
    int main(void)
    {
        int ret;
    
        if (!gpio_is_ready_dt(&spec)) {
            printk("Error: GPIO device %s is not ready\n", spec.port->name);
            return 0;
        }
    
        ret = gpio_pin_configure_dt(&spec, GPIO_OUTPUT_ACTIVE);
        if (ret < 0) {
            printk("Error %d: Failed to configure GPIO pin\n", ret);
            return 0;
        }
    
        printk("Setting GPIO HIGH on %d \n",spec.pin);
    
        /* Set GPIO HIGH */
        gpio_pin_set_dt(&spec, 1);
    
        while (1) {
            k_sleep(K_FOREVER); // Keep running
        }
    	return 0;
    }
    

    Above is my code I am not referring any PWM , I tried P0.08 also. But I am not getting any voltage in GPIO. 

Reply
  • #include <zephyr/kernel.h>
    #include <zephyr/device.h>
    #include <zephyr/drivers/gpio.h>
    #include <zephyr/sys/printk.h>
    
    static const struct gpio_dt_spec spec = GPIO_DT_SPEC_GET(DT_ALIAS(newpin), testpin_gpios);
    
    int main(void)
    {
        int ret;
    
        if (!gpio_is_ready_dt(&spec)) {
            printk("Error: GPIO device %s is not ready\n", spec.port->name);
            return 0;
        }
    
        ret = gpio_pin_configure_dt(&spec, GPIO_OUTPUT_ACTIVE);
        if (ret < 0) {
            printk("Error %d: Failed to configure GPIO pin\n", ret);
            return 0;
        }
    
        printk("Setting GPIO HIGH on %d \n",spec.pin);
    
        /* Set GPIO HIGH */
        gpio_pin_set_dt(&spec, 1);
    
        while (1) {
            k_sleep(K_FOREVER); // Keep running
        }
    	return 0;
    }
    

    Above is my code I am not referring any PWM , I tried P0.08 also. But I am not getting any voltage in GPIO. 

Children
Related