This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Unsupported Pin error when using pins on Port 1 of the nRF52840Dongle

Hi,

I am using the nRF52840 dongle and am seeing problems when I try to use port 1 pins.

For instance, if I try to write to pin P1.01, 

gpio_pin_set(dev, 32, 1);

I see this error

ASSERTION FAIL [(cfg->port_pin_mask & (gpio_port_pins_t)(1UL << (pin))) != 0U] @ WEST_TOPDIR/zephyr/include/drivers/gpio.h:750
        Unsupported pin
[00:00:04.584,503] <err> os: r0/a1:  0x00000004  r1/a2:  0x000002ee  r2/a3:  0x00000001
[00:00:04.584,533] <err> os: r3/a4:  0x00013b0a r12/ip:  0x2000124c r14/lr:  0x000023c9
[00:00:04.584,533] <err> os:  xpsr:  0x61000000
[00:00:04.584,564] <err> os: Faulting instruction address (r15/pc): 0x00010570
[00:00:04.584,564] <err> os: >>> ZEPHYR FATAL ERROR 4: Kernel panic on CPU 0
[00:00:04.584,564] <err> os: Current thread: 0x200012e0 (unknown)
[00:00:04.635,345] <err> fatal_error: Resetting system

I seem to be able to write to pins on port 0, i.e. pins with a number less than 32 but unable to write above 32.

How do I enable this?

Rod

Parents Reply Children
  • No, i get an error

    ../src/main.c:672:27: error: 'PORT1' undeclared (first use in this function)
      672 |  dev = device_get_binding(PORT1);
          |                           ^~~~~
    ../src/main.c:672:27: note: each undeclared identifier is reported only once for each function it appears in
    

  • Sorry, likely it is device_get_binding("PORT1") or possible device_get_binding("PORT_1")

    Best regards,
    Kenneth

  • Hi Kenneth,

    Both versions, ("PORT1") or ("PORT_1") compile and run however return NULL.

    my code

    dev = device_get_binding("PORT1");
    	if (dev == NULL) {
    		printk("Device Returned NULL\n");
    		return;
    	}

    prints "Device Returned NULL"


    Rod

  • That was weird, I was looking at this;
    https://devzone.nordicsemi.com/f/nordic-q-a/64225/uncontrollable-pins-in-nrf52840-gpio-port-1 

    Maybe you can spot the problem based on that code?

    Are you using the correct board for building?

    Best regards,
    Kenneth

  • Ok, I have taken this code and simplified it. (Im just using one pin and have removed the while loop)

    This is what it looks like now.

    #include <zephyr/types.h>
    #include <stddef.h>
    #include <errno.h>
    
    #include <zephyr.h>
    #include <sys/printk.h>
    #include <device.h>
    #include <devicetree.h>
    #include <drivers/gpio.h>
    
    
    //GPIO for Relay Ctl: port 1 pins 0-5
    #define rly1CtlPin0  0
    
    //100ms delay
    #define SLEEP_MS   100
    
    struct device *gpio1dev;
    
    void main(void)
    {
      gpio1dev = device_get_binding("GPIO_1");
      if(gpio1dev == NULL)
        printk("Uh oh! Something's wrong with the gpio devices!\n");
    
      gpio_pin_configure(gpio1dev, rly1CtlPin0, GPIO_OUTPUT_LOW);
    
    
        gpio_pin_set(gpio1dev, rly1CtlPin0, 1);
        printk("rly1CtlPin0 is ON\n");
        k_msleep(10*SLEEP_MS);
    
    }

    This runs as expected.

    I then try to move the pin to pin 47 (P1.15) and replace gpio1dev = device_get_binding("GPIO_1"); with gpio1dev = device_get_binding("PORT_1"); as suggested, code now like this

    #include <zephyr/types.h>
    #include <stddef.h>
    #include <errno.h>
    
    #include <zephyr.h>
    #include <sys/printk.h>
    #include <device.h>
    #include <devicetree.h>
    #include <drivers/gpio.h>
    
    
    //GPIO for Relay Ctl: port 1 pins 0-5
    #define rly1CtlPin0  47
    
    //100ms delay
    #define SLEEP_MS   100
    
    struct device *gpio1dev;
    
    void main(void)
    {
      gpio1dev = device_get_binding("PORT_1");
      if(gpio1dev == NULL)
        printk("Uh oh! Something's wrong with the gpio devices!\n");
    
      gpio_pin_configure(gpio1dev, rly1CtlPin0, GPIO_OUTPUT_LOW);
    
    
        gpio_pin_set(gpio1dev, rly1CtlPin0, 1);
        printk("rly1CtlPin0 is ON\n");
        k_msleep(10*SLEEP_MS);
    
    }

    I am getting this error 

    uart:~$ *** Booting Zephyr OS build v2.3.0-rc1-ncs1  ***
    Uh oh! Something's wrong with the gpio devices!
    ASSERTION FAIL [(cfg->port_pin_mask & (gpio_port_pins_t)(1UL << (pin))) != 0U] @ WEST_TOPDIR/zephyr/include/drivers/gpio.h:750
            Unsupported pin
    [00:00:00.026,184] <err> os: r0/a1:  0x00000004  r1/a2:  0x000002ee  r2/a3:  0x00000001
    [00:00:00.026,214] <err> os: r3/a4:  0x00011c52 r12/ip:  0x200011b8 r14/lr:  0x00001b81
    [00:00:00.026,214] <err> os:  xpsr:  0x61000000
    [00:00:00.026,214] <err> os: Faulting instruction address (r15/pc): 0x0000eab0
    [00:00:00.026,245] <err> os: >>> ZEPHYR FATAL ERROR 4: Kernel panic on CPU 0
    [00:00:00.026,245] <err> os: Current thread: 0x2000124c (unknown)
    [00:00:00.077,209] <err> fatal_error: Resetting system
    

Related