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
  • Are you able to share your code project, so I can take a closer look at the code, and try to reproduce the issue?

    I've created a project as reproducer. The main file configures GPIOTE to sense on four pins. It then deliberately goes into a power-off situation. In my situation, I had pins 3 and 4 connected to two sensors respectively. On startup, the program reports some sensing on pins 1 and 2 (which aren't connected to anything) and then powers off.

    The next bit is interesting. If I then sense something on one of my connected sensors then the device never goes to power down, or rather, it does, but then quickly wakes up again.

    More interesting: if I just sense up to two devices by commenting out the enabling of pin1 and pin2 sensing, all appears well. If I just enable one more then the continuous wake-up occurs.

    I recognise that this is slightly different to the original problem I reported, but there's a strong correlation between what I observed for my larger project and that of this reproducer: I can sense up to two sensors just fine, but beyond that, problems occur.

    Here's the project: https://github.com/titanclass/gpiote-nrfx-demo (I've configured just the pca10056 based target using SEGGER studio).

Children
Related