GPIOTE not working in NRF Connect SDK

I am migrating one of Segger Embedded Studio based project to NRF Connect SDK for nrf53 series of board. 

I migrated the function that uses GPIOTE feature using relevant APIs. However, it's not working as expected. I wasn't able to find any example codes as well on this.

Below is my code. I am trying to set a LED to high when the event (LOTOHI)  is triggered on TEST_PIN. However, when there is a state change from Low-High on TEST_PIN, the control isnt entering the handler function. I needed some help in correcting the code if something is incorrect in the way I have configured GPIOTE in the code. 

My prj.conf has CONFIG_NRFX_GPIOTE=y included

int gpio_init()
{
    gpio0 = device_get_binding(DEVICE_DT_NAME(DT_NODELABEL(gpio0)));
    gpio1 = device_get_binding(DEVICE_DT_NAME(DT_NODELABEL(gpio1)));

    led_err = gpio_pin_configure(gpio1, LED_PIN, GPIO_OUTPUT | GPIO_OUTPUT_INIT_LOW);
}


void in_pin_handler(nrfx_gpiote_pin_t pin, nrfx_gpiote_trigger_t trigger)
{
    LOG_INF("test");
    gpio_pin_set(gpio0, LED_PIN, HIGH);
}


void gpio_setting_init(void)
{
    nrfx_err_t err_code;
    static uint8_t in_channel;

    err_code = nrfx_gpiote_channel_alloc(&in_channel);
    
    err_code = nrfx_gpiote_init(NRFX_GPIOTE_DEFAULT_CONFIG_IRQ_PRIORITY);

   static const nrfx_gpiote_input_config_t in_config_test =
    {
        .pull = NRF_GPIO_PIN_NOPULL,
    };

   /*Finds rising edge instead of just toggling*/
    static const nrfx_gpiote_trigger_config_t trigger_config_test = {
		.trigger = NRFX_GPIOTE_TRIGGER_LOTOHI,
		.p_in_channel = &in_channel,
	};

	static const nrfx_gpiote_handler_config_t handler_config_test = {
		.handler = in_pin_handler,
	};

    /*gpiote initialization has been done in clock and timer initialization, no need to do it again*/
    err_code = nrfx_gpiote_input_configure(TEST_PIN, &in_config_test, &trigger_config_test, &handler_config_test);

    nrfx_gpiote_trigger_enable(TEST_PIN, true);


    LOG_INF("nrfx_gpiote initialized");
}

Parents Reply
  • I tried this by adding the below line. Its not working.

    #if defined(__ZEPHYR__)
        IRQ_DIRECT_CONNECT(NRFX_IRQ_NUMBER_GET(NRF_GPIOTE), IRQ_PRIO_LOWEST, nrfx_gpiote_irq_handler,
                           0);
    #endif

    Also, I had already included the below two lines in a function called earlier to generate clock using GPIOTE and GPPI. So, do we have to add it multiple times? 

    #if defined(__ZEPHYR__)
        IRQ_DIRECT_CONNECT(NRFX_IRQ_NUMBER_GET(NRF_GPIOTE), IRQ_PRIO_LOWEST, nrfx_gpiote_irq_handler,
                           0);
    #endif
    
        err_code = nrfx_gpiote_init(NRFX_GPIOTE_DEFAULT_CONFIG_IRQ_PRIORITY);

    Need some help in fixing this

Children
No Data
Related