Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

NRFX GPIOTE API and sensing with multiple pins recovering from system off

Hi there,

I've configured the NRFX API of GPIOTE to sense four pins to go from low to high. This works well while the device is on. When the device is off (via having called sd_power_system_off) then the sensing no longer appears to work. However, if I sense just one or two pins then it does work... I'm using nRF5_SDK_17.0.2_d674dde with an s140 soft device on the nRF52840 DK.

I'm wondering if I'm experiencing some race conditions as discussed in other threads.

Here's how my main calls up the GPIOTE initialisation function:

static void gpio_init()
{
    ret_code_t err_code;
    nrfx_gpiote_in_config_t pir_pin_config = NRFX_GPIOTE_CONFIG_IN_SENSE_LOTOHI(false);

    if (!nrfx_gpiote_is_init())
    {
        err_code = nrfx_gpiote_init();
        APP_ERROR_CHECK(err_code);
    }

    err_code = nrfx_gpiote_in_init(m_left_entry_exit_outside_pir_pin, &pir_pin_config, on_gpio_in_evt);
    APP_ERROR_CHECK(err_code);
    nrfx_gpiote_in_event_enable(m_left_entry_exit_outside_pir_pin, true);

    err_code = nrfx_gpiote_in_init(m_left_entry_exit_inside_pir_pin, &pir_pin_config, on_gpio_in_evt);
    APP_ERROR_CHECK(err_code);
    nrfx_gpiote_in_event_enable(m_left_entry_exit_inside_pir_pin, true);

    err_code = nrfx_gpiote_in_init(m_right_entry_exit_outside_pir_pin, &pir_pin_config, on_gpio_in_evt);
    APP_ERROR_CHECK(err_code);
    nrfx_gpiote_in_event_enable(m_right_entry_exit_outside_pir_pin, true);

    err_code = nrfx_gpiote_in_init(m_right_entry_exit_inside_pir_pin, &pir_pin_config, on_gpio_in_evt);
    APP_ERROR_CHECK(err_code);
    nrfx_gpiote_in_event_enable(m_right_entry_exit_inside_pir_pin, true);
}

This function is called each time the device wakes up from sleep. I'm assuming that the NRFX GPIOTE API is built to handle the situation where GPIO events exist on entry otherwise the one/two sensing scenario wouldn't work.

Thanks for any pointers. This behaviour has been troubling me for a few days.

Parents Reply Children
Related