nRF52832 won't wakeup after shutdown (nrf_gpio_cfg_sense_set & NRF_LPCOMP)

Hello,

We are building products using the nRF52832. We have customers that experience issues that the device won't turn on again after it was turned off. The device should turn on again after a button is pressed (pin sense) or an external power is connected to the device (LPCOMP) (see code snippet below). The issue can only be resolved by disconnecting the battery from the device so the MCU is doing a low power reset. So neither the pin sense nor the LPCOMP are working. Could it be that any of the peripherals are not turned off correctly or are still in any busy mode?
We tried very hard to reproduce this issue but we were not able.

We are using version 2.1.0 of the nRF Connect SDK. We are using the following peripherals and modules:
- ADC with SAADC (nrfx_saadc)
- PWM (nrfx_pwm) (5 PPI channels) for LED control
    - NRFX_TIMER_INSTANCE(3)
    - NRFX_TIMER_INSTANCE(1) (only to do some FX calculations)
- Shockburst (4 PPI channels), modified code to be compatible with nRF24L01+
- Settings API (NVS)
 
int MainStateMachine::shutdown_device() {
  // Disable all peripherals
  // ...
  SystemController::shutdown();
  return 0;
}


K_WORK_DEFINE(SystemController::shutdown_work,
              SystemController::shutdown_main_thread);

void SystemController::shutdown(void) {
  k_work_submit(&shutdown_work);  // -> Call from main thread
}

void SystemController::shutdown_main_thread(struct k_work *work) {
  /* Configure to generate PORT event (wakeup) on button 1 press. */
  nrf_gpio_cfg_input(BUTTON_PIN, NRF_GPIO_PIN_PULLUP);
  nrf_gpio_cfg_sense_set(BUTTON_PIN, NRF_GPIO_PIN_SENSE_LOW);

  //wake up from sleep mode if external voltage is applied
  NRF_LPCOMP->REFSEL = LPCOMP_REFSEL_REFSEL_Ref3_16Vdd;

  NRF_LPCOMP->PSEL = LPCOMP_PSEL_PSEL_AnalogInput6;
  NRF_LPCOMP->ANADETECT = 1;  // UP, Generate ANADETECT on upward crossing only

  NRF_LPCOMP->ENABLE = 1;
  NRF_LPCOMP->TASKS_START = 1;

  k_msleep(10);

  nrf_power_system_off(NRF_POWER);

  // Should never be reached
}

Do you have any idea what could block a normal shutdown of the device?

Thanks in advance!

Best regards,
Jonas Höfer
  • Do you have any idea what could block a normal shutdown of the device?

    My consern is that I can see you have very long delay between configuring wakeup sources until you enter system off mode. It's not unlikely during this time other threads and interrupts could be running, are you 100% sure none of these other threads and interrupts may be re-configuring gpio and/or lpcomp? Or that the change in configuration could cause those threads and interrupts to not run as expected?

    I am not aware of anything in specific that can cause what you see, but I guess you could start a watchdog in start of shutdown_main_thread(), such that a watchdog will at least cause a reset if it doesn't enter sleep.

    Kenneth

Related