sd_app_evt_wait and main loop behaviour after sd_power_system_off

Hi,

I'm struggling to understand the behaviour of our software running on an nrf52832 and SoftDevice S132 v2.0 (SDK11.0).

The main function is something like this:

for (;;)
{
    NRF_LOG_PRINTF("PM in\n");
    power_manage();
    NRF_LOG_PRINTF("PM out\n");

    if (bGoToSleep == true)
    {
        NRF_LOG_PRINTF("Going to sleep\n");
        nrf_drv_spis_uninit(&com_spi.spi_instance);

        if (sd_power_system_off() != NRF_SUCCESS)
        {
            NRF_LOG_PRINTF("Unable to go to system off\n");
        }
    }
}

the bGoToSleep variable is set when a certain SPI frame is received on SPI slave device (an STM32 MCU is the SPI master).

Everything is working normally most of the times, I have all the debug information ("PM in", "PM out", and all my other debug log from advertising events, SPI frames, ...).

But from time to time, it seems that after several cycle of sd_power_system_off, and a wake up by a GPIO, I only get the debug log from the events like advertising, I don't see anymore "PM in", "PM out", and the software never enter the "if (bGoToSleep == true)". As if the software never execute the code outside the software events.

Any idea of what I am doing wrong?

thank you

  • Hi opasutto,

    It is quite the old SDK version you are using. Let me begin with some questions:

    • Does power_manage() do anything other than calling sd_app_evt_wait()?

    • If there are not already such logs, could you add logs before and after the for(;;) loop to confirm if the system is reset after entering System OFF, and to check if execution broke out of the for(;;) loop somehow?

    • What hardware are you working on? It could be helpful to also toggle an LED before the loop, and toggle another LED after the loop. This would help rule out possibility of the experimental logging module malfunctioning.

    • Do you have this observation with multiple devices, or only on a certain one?
      Can you replicate this behavior in a development kit?

    Hieu

Related