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

GPIOTE interrupt has not trigger

I want to generate an interrupt event use pin30 when it goes from low->high or high->low. First I register a gpiote user by

app_gpiote_user_params_t app_gpiote_params =
{
    .pins_low_to_high_mask  = (1 << CONFIG_IO_BATDETECT),
    .pins_high_to_low_mask  = (0 << CONFIG_IO_BATDETECT),
    .config                 = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true),
};
//app_gpiote_params.config.pull = NRF_GPIO_PIN_PULLDOWN;
retval = app_gpiote_user_register_param(&m_batdetect_user_id,
                                        &app_gpiote_params,
                                        batterydetect_gpiote_event_handler);

CONFIG_IO_BATDETECT represent pin30,batterydetect_gpiote_event_handler is the handle function when interrupt generated.Then I use

APP_ERROR_CHECK(app_gpiote_user_enable(m_batdetect_user_id));

to enable GPIOTE.I also change the APP_GPIOTE_MAX_USERS from 2 to 3:

#define APP_GPIOTE_MAX_USERS            3

in the main.c.The event handle function as follow:

		APP_ERROR_CHECK(app_gpiote_user_disable(m_batdetect_user_id));
	DBG0_EVT0("jack:m_keyboard: Disabled");
	if (event_pins_low_to_high & TEST_PIN_L2H)
	{
			DBG0_EVT0("jack:event_pins_low_to_high");
	}
	
	if (event_pins_high_to_low & TEST_PIN_H2L)
	{
			DBG0_EVT0("jack:event_pins_high_to_low");
	}
	
	DBG0_EVT0("jack:m_keyboard: enabled");
	APP_ERROR_CHECK(app_gpiote_user_enable(m_batdetect_user_id));

While the function has never been triggered. Have I miss something ? The SDK is v11.0.0 by the way.

Parents
  • I assume you define app_gpiote_user_register_param() yourself ?

    Please be aware that app_gpiote is deprecated, and you should use gpiote driver instead.

    Have you tried to follow the documentation ? This code worked for me:

    APP_GPIOTE_INIT(1);
        uint32_t  low_to_high_bitmask = (1 << 13); // Bitmask to be notified of transition from low to high for GPIO 0-3
        uint32_t  high_to_low_bitmask = (1 << 13); // Bitmask to be notified of transition from high to low for GPIO 0-2
        retval = app_gpiote_user_register(&m_example_user_id,
                                      low_to_high_bitmask,
                                      high_to_low_bitmask,
                                      example_gpiote_event_handler);
        APP_ERROR_CHECK(retval);
        nrf_gpio_cfg_input(13,NRF_GPIO_PIN_PULLUP);
    
        retval = app_gpiote_user_enable(m_example_user_id);
        APP_ERROR_CHECK(retval);
    

    I found that I need to configure the pin as input after registering to make it work, pretty strange.

Reply Children
No Data
Related