Multiple GPIOE Interrupts causing issues with CAN Bus

Hi all,

I have an issue regarding multiple GPIO interrupts. Following case:

I am using MCP251xfd can module connected via SPI and an interrupt GPIP      

  int-gpios = <&gpio0 26 GPIO_ACTIVE_LOW>;    // <&gpio0 11 GPIO_ACTIVE_LOW>;

&spi2 {
	status = "okay";
	cs-gpios = <&gpio0 22 GPIO_ACTIVE_LOW>;

	mcp251xfd: can@0 {
		compatible = "microchip,mcp251xfd";
		reg = <0x0>;
		bitrate = <500000>;        // 500kBit
		sample-point = <800>;      // 80%
		bitrate-data = <2000000>;  // 2000 kBit
		sample-point-data = <800>; // 80%
		osc-freq = <40000000>;   // <16000000>; // 40 MHz
		spi-max-frequency = <1000000>; // <18000000>;
		int-gpios = <&gpio0 26 GPIO_ACTIVE_LOW>;    // <&gpio0 11 GPIO_ACTIVE_LOW>;
		status = "okay";
	};
};

I used this setup for long time and it worked flawlessly.


Then I added an external Interrupt to a "seemingly" unrelated GPIO. PIN 0 13:

	gpio_keys {
		compatible = "gpio-keys";

		input_fast: input_fast {
			gpios = <&gpio0 13 (GPIO_PULL_UP | GPIO_ACTIVE_HIGH)>;
		};		
	};

I set it up like this:

int InputFast::setup()
{
    int ret;

    if (!device_is_ready(input_fast.port) )
    {
        printk("Error: Input fast device not ready\n");
        return -ENODEV;
    }

    // Configure fast pins as input with pull-ups
    ret = gpio_pin_configure_dt(&input_fast, GPIO_INPUT);
    if (ret < 0)
    {
        printk("Error: Input fast GPIO devices not ready\n");
        return ret;
    }

    gpio_init_callback(&input_fast_cb_data, input_fast_handler, BIT(input_fast.pin));
    gpio_add_callback(input_fast.port, &input_fast_cb_data);

    // Configure interrupt
    ret = gpio_pin_interrupt_configure_dt(&input_fast, GPIO_INT_EDGE_RISING);// GPIO_INT_EDGE_BOTH);
    if (ret < 0)
    {
        printk("Error: Input fast interrupt not ready\n");
        return ret;
    }

    printk("Initialized Input fast\n");
    return 0;
}

But whenever I setup this GPIO Interrupt, then the CAN interrupt stops functioning. I Understand that they are underlying connected by the same GPIOE and use the same InterruptHandler at the bottom. But I think they should use different channels for the input event and the InterruptHandler should be able to forward the callback accordingly?

Parents
  • Hi!

    That sounds strange, could you check the compiled device tree (zephyr.dts), and see if GPIOs etc are set correctly there as well?

  • I attached the compiled zephyr.dts

    Important for us the following pin:

    	/* node '/gpio_keys' defined in ../git/e-shift/firmware/build_gear/zephyr/board_overlays/gear.overlay:14 */
    	gpio_keys {
    		compatible = "gpio-keys"; /* in ../git/e-shift/firmware/build_gear/zephyr/board_overlays/gear.overlay:15 */
    
    		/* node '/gpio_keys/input_fast' defined in ../git/e-shift/firmware/build_gear/zephyr/board_overlays/gear.overlay:17 */
    		input_fast: input_fast {
    			gpios = < &gpio0 0xd 0x10 >; /* in ../git/e-shift/firmware/build_gear/zephyr/board_overlays/gear.overlay:18 */
    		};
    	};

    and the can setup. The Setup for the gpio is also still defined for button0. Not sure if this is a problem.

    8032.zephyr.dts

Reply
  • I attached the compiled zephyr.dts

    Important for us the following pin:

    	/* node '/gpio_keys' defined in ../git/e-shift/firmware/build_gear/zephyr/board_overlays/gear.overlay:14 */
    	gpio_keys {
    		compatible = "gpio-keys"; /* in ../git/e-shift/firmware/build_gear/zephyr/board_overlays/gear.overlay:15 */
    
    		/* node '/gpio_keys/input_fast' defined in ../git/e-shift/firmware/build_gear/zephyr/board_overlays/gear.overlay:17 */
    		input_fast: input_fast {
    			gpios = < &gpio0 0xd 0x10 >; /* in ../git/e-shift/firmware/build_gear/zephyr/board_overlays/gear.overlay:18 */
    		};
    	};

    and the can setup. The Setup for the gpio is also still defined for button0. Not sure if this is a problem.

    8032.zephyr.dts

Children
Related