I am trying to track down the source of unexplained current spikes visible on the Power Profiler Kit 2 when the nRF52832 should be in sleep mode.
I have stripped the project down to as bare bones as possible (see below) and tried every possible solution from Google's AI (most of which were hallucinations...) to no avail.
#include <zephyr/kernel.h>
int main(void) {
for(unsigned int i = 0; i < 2000; i++) {
k_msleep(1);
}
for(;;) {
const unsigned int width = 250;
k_msleep(5 * 1000 - width);
for(unsigned int i = 0; i < width; i++) {
k_msleep(1);
}
}
}
# prj.conf CONFIG_BOOTLOADER_MCUBOOT=y CONFIG_BT=n CONFIG_CLOCK_CONTROL=y CONFIG_LOG=n CONFIG_MCUMGR=n CONFIG_PM_DEVICE=y CONFIG_SERIAL=n CONFIG_TICKLESS_KERNEL=y CONFIG_TIMESLICING=n CONFIG_UART_CONSOLE=n CONFIG_WATCHDOG=n CONFIG_SHELL=n
I am building using v3.2.3 of the SDK using the nRF Connect extension in VS Code
I'm using a custom board that does _NOT_ exhibit these spikes when using code built using v2.5.x of the SDK (not a hardware problem!!!)
The board uses an external crystal for the 32.768 kHz

Things I've already tried:
- PPK2 is in "source" mode, no other connections to the board (including completely disconnecting the JTAG cable)
- power cycling the board after programming and before capturing the plot of current
- disabling all 20 PPI channels at the start of main (no effect on most, one actually causes the k_sleep to never wake up...)
- stopping all 3 timers at the start of main
- removing all mentions of peripherals (I2C, SPI, PWM, etc.) from the C code, prj.conf, and board files
- switching from the DC/DC regulator to the LDO (again, same hardware does not show the problem with older SDKs!)
- using the debugger to look for unexpected threads or IRQs
- adding special code to main() to differentiate between legitimate wake behavior (and code resets) and the unexpected wakeups - the legit ones are the "fat" ones.
