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

Achieving lowest possible sleep current on nRF52840

We designed a board based on the nRF52840, and are using nrf5 SDK 17.1.0 with S140 SoftDevice. The board has an RTC, LSM6DSO as IMU, an opamp front end for the analog inputs and an EEPROM (QSPI serial). The board is powered by 1.8V using circuit 5 here

The opamp front end and the EEPROM are on a separate power rail, switched on an off by a nRF GPIO, so use no power when off (aside from parasitic draw thru unpowered pins, which I tried to avoid). The device also has a ship mode switch for the battery controlled by another GPIO. The 2 electronic switches are TPS22916BYFPT, extremely low poer and low Ron.

The nRF can be woken up from sleep either from the external RTC or the IMU, each one on a GPIO pin configured for wakeup. The device is put to sleep using sd_power_system_off(). We are also using sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE)

To reduce the chance of parasitic draw, I set all GPIOs to the default state using nrf_gpio_cfg_default(). I do not uniitialize all peripherals, though, and I'm unclear if sd_power_system_off does it. 

I also read about RAM being powered when sleeping, but we do not need that. I read the documentation multiple times, and I have to admit I'm lost. What is the best way to power off pretty much everything, with only the exclusion of the GPIO used for wakeup and the two GPIOs keeping the power rails on? Our code fully re-initializes when waking up from sleep, so we do not want to retain anything anyway.

I'm measuring 650 uA in sleep now, which is insanely high. I have seen sleep currents in the 17uA range using the LSM6DSO and nRF52840 (and the LSM6DSO settings are the same), so there is something seriously wrong

Any pointer to help troubleshoot is really appreciated

EDIT: it's clear that my sleep power draw (0.65mA) is due to peripherals being enabled, in hindsight that should have been obvious. Add on question: it's hard to know which peripherals have been enabled before calling the sleep function, that depends on how the user interacted with the system. Is there a reliable way to query which peripherals have been initialized. Calling the unit function if the peripheral has not been initialized, causes an error. I know I can set flags in my code, but I wonder if there is a way to check if a peripheral has been enabled. Or a quick way to turn off all clocks for all peripherals (I assume that the GPIO doesn't need a clock)