Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

LPN: Wakeup from System ON does not work properly outside the Debug session

I have problem with wakeup of Low Power Node from System ON sleep mode. In debug session code works as expected, however outside the session something gets wrong.

The node is put to sleep in infinite loop of main using sd_app_evt_wait() function (after that function application code is placed). 

Several wakeup sources are set - GPIO, RTC and APP_Timer. When GPIO is triggered, power consumption rises corresponding to MCU active state, however code after the sd_app_evt_wait is not processed properly (it looks like code after the sleep function is skipped).

GPIO is configured to be used with GPIOTE, code of initialization below:

err_code = nrfx_gpiote_init();
APP_ERROR_CHECK(err_code);

nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true);
in_config.pull = NRF_GPIO_PIN_NOPULL;

err_code = nrf_drv_gpiote_in_init(BUTTON_PIN, &in_config, in_pin_handler);
APP_ERROR_CHECK(err_code);

nrf_drv_gpiote_in_event_enable(BUTTON_PIN, true);

Pin is pulled low with external pull-down, and in_pin_handler is called (checked by lighting up the led). Handler checks the pin state and starts polling timer. Code in main checks for polling result (state of the button). However outside the debug session changes in button state are rarely detected. Button is debounced during polling and that part looks working fine.

Build configuration set same for debugger and no-debugger. I assume that problem relies in sd_app_evt_wait call as in debugger session MCU is always active?

Parents
  • Thank you for response, Amanda and sorry for late reply.

    Versions: Mesh SDK is v5.0.0, nRF52 SDK 17.0.2, SoftDevice s132_nrf52_7.0.1 also tried s132_nrf52_7.2.0.

    I looked again to this problem and found out that device is reset if I try to initiate friendship after system is wake up. I also tried to add delay between wake up and initiate friendship function, but this did not change anything. And as I mentioned problem occurs only when device is not in debug session.

    Also I tried to call the function from both thread and interrupt context, however reset appears in both ways. Initiate friendship calls mesh_lpn_friend_request function.

    I also checked circuitry of reset pin, it is pulled-up externally by 22k resistor, not sure if it could cause the problem. I think pin is also pulled-up automatically by hardware when pin function is set to be reset input?

  • Hi, 

    The default mesh configuration doesn't reset the device in case of assertion. If it is an assertion triggered somewhere in the code, mesh_assertion_handler is not redefined, the device will be put on sleep. Another way to verify that could be to set an infinite loop in all interrupt fault handlers and then try to trace the stack. SoftDevice redefines HardFault_Handler, but it should be possible to give a different name for it.

    mesh777 said:
    I also checked circuitry of reset pin, it is pulled-up externally by 22k resistor, not sure if it could cause the problem. I think pin is also pulled-up automatically by hardware when pin function is set to be reset input?

    It should not be the issue, but you can remove the 22k resistor and see if it changes anything. You also could upload the schematic, so we can check it for you. 

    Regards,
    Amanda

Reply
  • Hi, 

    The default mesh configuration doesn't reset the device in case of assertion. If it is an assertion triggered somewhere in the code, mesh_assertion_handler is not redefined, the device will be put on sleep. Another way to verify that could be to set an infinite loop in all interrupt fault handlers and then try to trace the stack. SoftDevice redefines HardFault_Handler, but it should be possible to give a different name for it.

    mesh777 said:
    I also checked circuitry of reset pin, it is pulled-up externally by 22k resistor, not sure if it could cause the problem. I think pin is also pulled-up automatically by hardware when pin function is set to be reset input?

    It should not be the issue, but you can remove the 22k resistor and see if it changes anything. You also could upload the schematic, so we can check it for you. 

    Regards,
    Amanda

Children
No Data
Related