after set GPIO pin as active low exception fatal error occurred in debugging mode

Hi

     For nRF7002-DK, SDK Version 2.52,I gernate gpio port and set it as active low as below. after gpio pin set as active low, on debugging mode occurred exception fatal error, I can't add any break point for debug after that.it's only simple output gpio pin setting why cause fatal error as below? 

yaml for binding
include: base.yaml

compatible: "nordic,custom-device"
description: Custom devicetree device
properties:
  in-gpios:
    type: phandle-array
    description: input gpio pins
    required: true
  out-gpios:
    type: phandle-array
    description: output gpio pins
    required: true

overlay
/{
	custom_device: custom_device { 
        compatible = "nordic,custom-device";
        status = "okay";
		in-gpios = <&gpio1 13 GPIO_ACTIVE_HIGH>;
        out-gpios = <&gpio1 11 GPIO_ACTIVE_HIGH>;
    };
};

static const struct gpio_dt_spec output_gpio = GPIO_DT_SPEC_GET(CUSTOM_DEVICE, out_gpios);
   if (!device_is_ready(output_gpio.port))
    {
        printk("Output GPIOs not ready\n");
        return;
    }
gpio_pin_set(&output_gpio,output_gpio.pin,GPIO_ACTIVE_LOW);
Error Fatal in debugging mode
Best Regards
    Tina
Parents
  • Hi,

     

    Looks like there's a couple of steps missing, for instance the configuration.

    Here's what I used:

    /*
     * Copyright (c) 2012-2014 Wind River Systems, Inc.
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    #include <stdio.h>
    #include <zephyr/kernel.h>
    #include <zephyr/drivers/gpio.h>
    
    const struct gpio_dt_spec output_gpio = GPIO_DT_SPEC_GET(DT_NODELABEL(custom_device), out_gpios);
    const struct gpio_dt_spec input_gpio = GPIO_DT_SPEC_GET(DT_NODELABEL(custom_device), in_gpios);
    
    int main(void)
    {
    	printf("Hello World! %s\n", CONFIG_BOARD);
    	if (!device_is_ready(output_gpio.port))
    	{
    		printk("Output GPIOs not ready\n");
    		return;
    	}
    	if (gpio_pin_configure_dt(&output_gpio, GPIO_OUTPUT) != 0) {
    		printk("Output configure failed\n");
    	}
    
    	printk("Output pin %d\n", output_gpio.pin);
    	printk("Input pin %d\n", input_gpio.pin);
    	while (1) {
    		gpio_pin_set(output_gpio.port, output_gpio.pin, 0);
    		k_msleep(3000);
    		gpio_pin_set(output_gpio.port, output_gpio.pin, 1);
    		k_msleep(3000);
    	}
    
    
    	return 0;
    }
    

     Could you try this and see if that works better?

     

    Kind regards,

    Håkon

Reply
  • Hi,

     

    Looks like there's a couple of steps missing, for instance the configuration.

    Here's what I used:

    /*
     * Copyright (c) 2012-2014 Wind River Systems, Inc.
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    #include <stdio.h>
    #include <zephyr/kernel.h>
    #include <zephyr/drivers/gpio.h>
    
    const struct gpio_dt_spec output_gpio = GPIO_DT_SPEC_GET(DT_NODELABEL(custom_device), out_gpios);
    const struct gpio_dt_spec input_gpio = GPIO_DT_SPEC_GET(DT_NODELABEL(custom_device), in_gpios);
    
    int main(void)
    {
    	printf("Hello World! %s\n", CONFIG_BOARD);
    	if (!device_is_ready(output_gpio.port))
    	{
    		printk("Output GPIOs not ready\n");
    		return;
    	}
    	if (gpio_pin_configure_dt(&output_gpio, GPIO_OUTPUT) != 0) {
    		printk("Output configure failed\n");
    	}
    
    	printk("Output pin %d\n", output_gpio.pin);
    	printk("Input pin %d\n", input_gpio.pin);
    	while (1) {
    		gpio_pin_set(output_gpio.port, output_gpio.pin, 0);
    		k_msleep(3000);
    		gpio_pin_set(output_gpio.port, output_gpio.pin, 1);
    		k_msleep(3000);
    	}
    
    
    	return 0;
    }
    

     Could you try this and see if that works better?

     

    Kind regards,

    Håkon

Children
Related