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

P1.04 Configuration on nrf5340

I am using the nrf5340PDK and i am trying to have P1.04 trigger an interrupt on a high to low transition.

attached is my overlay file and my main.c to initialize the GPIO.

if i set the pin in the overlay to (almost) any port0 pin this works.  but if i set the GPIO to 36 (P1.04) it does not work.

what am i missing?

/ {
	
	buttons {
		compatible = "gpio-keys";
		MBR_DETECT: mbr_detect {
			gpios = <&gpio0 0x24 (GPIO_PULL_UP|GPIO_ACTIVE_LOW)>;
			label = "MBR_DETECT";
		};
	};
};

#define   MBR_PORT  DT_GPIO_LABEL(DT_NODELABEL(mbr_detect), gpios)
#define   MBR_PIN   DT_GPIO_PIN(DT_NODELABEL(mbr_detect),   gpios)
#define   MBR_FLAGS DT_GPIO_FLAGS(DT_NODELABEL(mbr_detect), gpios)
 .
 .
 .
 .
 void main(void)
{
	const struct device *button;
	const struct device *led;
	int ret;
 
        button = device_get_binding(MBR_PORT);
	if (button == NULL) {
		printk("Error: didn't find %s device\n", MBR_PORT);
		return;
	}

	ret = gpio_pin_configure(button, MBR_PIN,(GPIO_INPUT |MBR_FLAGS));
	if (ret != 0) {
		printk("Error %d: failed to configure %s pin %d\n",
		       ret, MBR_PORT, MBR_PIN);
		return;
	}

	ret = gpio_pin_interrupt_configure(button,
					   MBR_PIN,
					   GPIO_INT_EDGE_FALLING);
	if (ret != 0) {
		printk("Error %d: failed to configure interrupt on %s pin %d\n",
			ret, MBR_PORT, MBR_PIN);
		return;
	}

	gpio_init_callback(&button_cb_data, button_pressed, BIT(MBR_PIN));
	gpio_add_callback(button, &button_cb_data);

Parents Reply Children
  • i Have tried to edit the following files to get P1 in the NS domain.

    i changed nrf/subsys/spm/kconfig


    config SPM_NRF_P1_NS
    	bool "GPIO P1 is Non-Secure"
    	default y
    	help 
    		WRC added this to place Port 1 in Non Secure Domain

    I changed the SPM.c

    #ifdef NRF_P1
    		PERIPH("NRF_P1", NRF_P1, CONFIG_SPM_NRF_P1_NS),
    #endif
    
    if (IS_ENABLED(CONFIG_SPM_NRF_P1_NS)) {
    		/* Configure GPIO port 1 pins to be Non-Secure */
    		NRF_SPU->GPIOPORT[1].PERM = 0;
    	}

    I added this line to the prj.conf

    CONFIG_IS_SPM=y

    and in my .overlay file i have this

    / {
    	
    	buttons {
    		compatible = "gpio-keys";
    		MBR_DETECT: mbr_detect {
    			gpios = <&gpio1 0x4 (GPIO_PULL_UP|GPIO_ACTIVE_LOW)>;
    			label = "MBR_DETECT";
    		};
    	};
    };

    when itry and build in SES i get the following error

    C:/Users/Wes/ncs/v1.4.0/zephyr/include/toolchain/gcc.h:62:36: error: static assertion failed: ""

    if i need to edit the SPM to get the P1 to work, what have i missed or done incorrectly?

    thanks

  • I got it working.  I needed to remove the 

    CONFIG_IS_SPM=y from the prj.conf file.

    it works know

    thanks i will close

Related