Hello, I am developing an application with nRF52 DK. softdevice 112 and SDK V15.2.0. This is a "continuation" from my previous ticket (https://devzone.nordicsemi.com/f/nordic-q-a/64125/system-on-sleep-mode-problems-sometimes-500ua-draw-sometimes-7-5ma-draw-with-logging-and-debugging-disabled).
I successfully lowered my current draw from 7mA to 500uA. Now I need this sleep mode current to get even lower, as low as possible in the 2-3uA range or lower. I want to enter System ON sleep mode. I have found from previous devzone posts that 500uA draw in sleep mode can mean that the hf clock is running, when the lf clock should be used. However, I am using a soft device and it is my understanding that the softdevice should automatically handle clock management. I.E. use the HF clock during advertising/ble events and then switch to the LF clock when there is no ble activity and the antenna is not needed. I have tested that the lf clock is running by calling "nrf_clock_lf_is_running()" after I initialize the softdevice, and the function returns true which must mean the lf clock is indeed running. Here is what the power analysis looks like when using the PPK:
The brief protocol for my application is: turn on, read saadc data, turn off saadc, advertise, connect, send data, repeat. I do use nrf drv timer instance 1 while using the SAADC, however after I'm done reading data I disable and uninitialize this timer. When I am done reading SAADC data I disable and uninit the nrf drv timer, free the ppi channel (which also disables it), and uninit the saadc. I also clear and uninit some GPIO pins I use, and then uninit the gpiote peripheral itself.
In my sdk_config.h, NRF_SDH_CLOCK_LF_SRC, NRFX_CLOCK_CONFIG_LF_SRC and CLOCK_CONFIG_LF_SRC are all set to 0 which means NRF_CLOCK_LF_SRC_RC. While the RC and Xtal lf clock options should be approximately the same (I've read 2-3% lower current draw using external lf xtal), I wanted to see if using the xtal would help at all. So, I change the sdk_config.h clock settings to 1 which means NRF_CLOCK_LF_SRC_XTAL. However when I do this, my application no longer runs and instead breaks with a fatal error. I have not changed the default configurations of SB1, 2, 3, and 4 on the nRF52 DK as they are by default setup to use the external xtals. I have also disabled all logging defines in my sdk _config.h as well as backend_rtt. Attached is a screenshot of the error, which is thrown when I check the return code from "nrf_pwr_mgmt_init()":
The error code is 0x7, and then the id is 0x4001. Error 0x7 indicates incorrect parameters, but the function doesn't even take any parameters. I think this could be unrelated to the power draw issue, but it is strange that when I set my lf clock source to xtal I get this behavior. I have tried calling "nrf_clock_lf_src_set()" in main, passing the xtal as the parameter, and this does not cause any error. However, the current draw stays the same.
To get my current draw down to 2-3uA range during sleep, do I have to manually turn off the hf clock and "switch" to the lf clock? I use an rtc timer during sleep, using the app_timer module, which supposedly runs off rtc and lf clock. If I need to manually turn off the hf clock, can someone show me some examples on how to do this? Or, do I need to uninitialize some/all of the ble stack after I am done advertising/sending data and before I put the device to sleep? I can keep my device set to use the RC oscillator for the lf clock if this will still allow me to achieve 2-3uA draw, if that is helpful compared to trying to solve the above error. Any help here would be greatly appreciated. Thanks!