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.
Parents
  • I'm not sure i understand the problem statement. You are making an application that should wake up from sleep once acceleration has been detected and your questions is:

    1. Does sd_app_evt_wait () output a SLEEP to the terminal? 
    2. Why doesn't the device wake up from Sleep when you run sd_app_evt_wait ()?

    And please use the insert code option when you include code :) 

  • Jared
    Thank you for your reply.
    >1. Does sd_app_evt_wait () output a SLEEP to the terminal?
    >
    With sd_app_evt_wait (), SLEEP is executed for the second time.
    >2. Why doesn't the device wake up from Sleep when you run sd_app_evt_wait ()?
    >
    If it is an application timer operation for a short time, it will recover from SLEEP, but it seems that it will not return in a long time such as 12 hours. I do not know the cause.

    >And please use the insert code option when you include code :)
    >
    We are sorry for your inconvenience as this post is not used.
Reply
  • Jared
    Thank you for your reply.
    >1. Does sd_app_evt_wait () output a SLEEP to the terminal?
    >
    With sd_app_evt_wait (), SLEEP is executed for the second time.
    >2. Why doesn't the device wake up from Sleep when you run sd_app_evt_wait ()?
    >
    If it is an application timer operation for a short time, it will recover from SLEEP, but it seems that it will not return in a long time such as 12 hours. I do not know the cause.

    >And please use the insert code option when you include code :)
    >
    We are sorry for your inconvenience as this post is not used.
Children
Related