Hello,
I am now working on a product concept which uses RTC module to retain date and time. To speed up the development, I started with ble_sdk_app_template and I am modifying it to satisfy the requirements of the project. The project uses RTC module to retain time and date (I use the nrf_drv_rtc_counter_get() function to retrieve number of ticks of the RTC module which is then with my custom functions converted to UNIX time and converted to date+time with gmtime functions).
If the module is not connected to the phone and advertising is active, after the specified period, the module should shut itself down (as it is implemented in the original example which I tested and it works). I understand that I can't use the standard sleep_mode_enter routine as sd_power_system_off routine shuts down all peripherals, including RTC (which indeed is not running until wake-up). The only source of wake-up should be the button which is set before going to sleep with nrf_gpio_cfg_sense_input.
I tried to simply replace the sd_power_system_off with sd_app_evt_wait in the sleep_mode_enter routine, expecting it to put the CPU to sleep, followed by NVIC_SystemReset to reset the MCU upon next activation of the button.
However, I was not able to get this to work as the MCU never goes to sleep.
So far, I tried disabling every peripheral and module which I've added could generate an interrupt (UART, led_softblink), tried clearing the FPU interrupts manually (as discussed in other posts on this forum), disabled the RTC interrupts (both TICK and COMPARE) before going to sleep and nothing worked.
I am starting to think that there has to be something done to the SoftDevice before going to sleep. Is it possible to determine which interrupt or event causes the wake-up? Could you please advise on a correct procedure for modifying sleep_mode_enter() to keep the RTC running, while letting the CPU sleep?
Thank you very much for your time.
Best Regards,
Marek.