I'm working on a custom board using an nRF52840 for a sensor Tag (light, hum, temp, press)
https://www.homesmartmesh.com/docs/microcontrollers/nrf52/thread_sensortag/
I would like to use openthread over Zephyr. Using a previous nRF-SDK without Zephyr is being considered, but this ticket is only about the Zephyr solution. Given that Zephyr needs some 250 ms to boot, and that I would like to use the internal RTC to periodically wakeup and take measures, the target solution is to use the kernel sleep in low power mode and keep the RAM context. But it seems that the in `zephyr\soc\arm\nordic_nrf\nrf52\power.c` only `PM_STATE_SOFT_OFF` is implemented. So I'm still not sure if I did not wrongly configure, but in the meanwhile, I'm giving it a try to patch zephyr and implement the missing power modes myself.
I started by implementing `pm_policy_next_state` in the main.c of the tag_power sample also the `pm_min_residency` table in the same file
https://github.com/HomeSmartMesh/sdk-hsm-sensortag/blob/f0b72b1786f0ca93666defaa23e008f85fcd4c9f/samples/tag_power/src/main.c#L52
And I patched Zephyr with the following content, I did not integrate this yet, so the modified file is in the read me
https://github.com/HomeSmartMesh/sdk-hsm-sensortag/tree/main/samples/tag_power#zephyr-patch
The problem now seems to be more related to Zephyr configuration where the idle task keeps ticking in 264 uS periods, that means every period the RTC is configured to wakeup after 264 uS and sleep again which obviously due to the overhead reduces the low power performance.
The `CONFIG_PM` is used as I'm building with `west build -b nrf52840_sensortag -- -DCONF_FILE=prj-low.conf`
https://github.com/HomeSmartMesh/sdk-hsm-sensortag/blob/f0b72b1786f0ca93666defaa23e008f85fcd4c9f/samples/tag_power/prj.conf#L2
and in `hsm\samples\tag_power\build\zephyr\.config` I could verify that the config `CONFIG_TICKLESS_KERNEL=y` is enabled.
This is the startup sequence and the whole sample test run
And this is a zoom over the first two tests lines 89,90 with 1 ms, hen the test with 250 ms line 98 where we see that the idle task keeps ticking over the sleep and wakeup functions where the debug pins are driven
So my question is, does anyone knows why despite the low power mode config the idle task keeps ticking ?


