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

Power off by acceleration detection with application timer.

We, I am using nRF 5 SDK v 14.2.0.
This time, without using WDT, using only the application timer,
We are developing a process to send data by detecting acceleration and interrupting acceleration.
In main.c and the acceleration detection function, it is as follows.
int main(void)
{
            gpio_init();
            nrf_drv_gpiote_in_event_enable(PIN_IN, true);
        for (;;)
        {
            while (!( accel_int_detect  )){
                    NRF_LOG_INFO("----while start.----\n");
                    NRF_LOG_FLUSH();
                    err_code = sd_app_evt_wait();
                    APP_ERROR_CHECK(err_code);
                    nrf_delay_ms(1000);
            }
            nrf_drv_gpiote_in_event_disable(PIN_IN);
            send_mail();
        }
}

static void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
    uint8_t ret;
    NRF_LOG_INFO("%s %d", __func__, __LINE__);
    NRF_LOG_FLUSH();
    nrf_drv_gpiote_in_event_disable(PIN_IN);
    NRF_LOG_INFO("--- INT disabled");
    accel_int_detect = true;
    }
    NRF_LOG_INFO("Motion detected");
    NRF_LOG_FLUSH();
    __SEV();
    return;
}

void gpio_init(void)
{
    ret_code_t err_code;
    if (!nrf_drv_gpiote_is_init())
    {
        err_code = nrf_drv_gpiote_init();
        APP_ERROR_CHECK(err_code);
    }
    nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true);
    err_code = nrf_drv_gpiote_in_init(PIN_IN, &in_config, in_pin_handler);
    APP_ERROR_CHECK(err_code);
    nrf_drv_gpiote_in_event_enable(PIN_IN, true);
}
A.
When checking in SEGGER debug mode,
---- while start .----
Is displayed twice and then it becomes SLEEP.
sd_app_evt_wait ();
Is SLEEP such a thing like that?

B.
In this state, when I made it work, it got in SLEEP state with sd_app_evt_wait ();
After several hours the power has been turned off.
If you operate with the acceleration detection part commented, it will operate normally after several hours.
As with the WDT, if you operate the acceleration handler in a state where reset is not applied, memory leaks
Will it be turned off?
Please let me know if there is any countermeasure.
Thank you.
Related