This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

RTC turns off when using idle_state_handler in ble_app_template

Hi

Im developing an application that will wake up on RTC every 15 minutes. My issue is that when using idle_state_handle, which in turn calls sd_ble_app_wait, the RTC will turn off, and therefore will not wake up from this source. This is verified using prints to a terminal. Ive tried using both app_timer and configuring RTC2 myself, both have the issue. 

My question is how can i configure the sd_ble_app_wait to first of all not turn off the RTCs  and second of all, how can i choose to wake up from RTC?

Im on windows, using SDK17 on a 52840 using a devkit PCA10056. 

  • configuring RTC2 myself, both have the issue. 

     Have you enabled the compare event's interrupt? If not, it won't wake up the CPU. 

     

    My question is how can i configure the sd_ble_app_wait to first of all not turn off the RTCs  and second of all, how can i choose to wake up from RTC?

    sd_app_evt_wait does not turn off the RTCs. 

  • I clearly see an output when using RTC2, so im pretty confident that the compare event works as intended. 

    I've isolated the problem to happen only when advertising stops. Does anything happen when advertising stops and no connections has been made? perhaps it enters system_OFF when advertising stops

  • ThomasN12 said:
    perhaps it enters system_OFF when advertising stops

     Only from the application side, the SoftDevice does not enter SystemOff unless the application initiates it. I suggest you look through your code for any such calls. See sd_power_system_off

     

    ThomasN12 said:
    I clearly see an output when using RTC2, so im pretty confident that the compare event works as intended. 

     How do you see the output? 

  • I have found the solution. 

    When using the ble_app_template, the function sleep_mode_enter is called, where it enters system_OFF. This happens in the on_adv_evt - which explains all my issues with the RTC not working after advertising stops.

    I do have a follow up question - How can i choose which system_ON state it enters - say I want to wake up on any event compared to wake up on RTC? Is this the same state, but dependent on which peripherals are actually running on the chip during sleep or are there actual registers that needs to be set during shutdown?

  • ThomasN12 said:
    say I want to wake up on any event compared to wake up on RTC? Is this the same state, but dependent on which peripherals are actually running on the chip during sleep or are there actual registers that needs to be set during shutdown?

    If you enable any Peripheral Interrupt then that is a wake-up source from SystemON, Idle (sleep). Ie. turn on the interrupt of any of the RTC's COMPARE events and it will wake up the CPU, execute that interrupt handler and return to whatever execution state the CPU was in before it went to sleep. 

    See for instance the RTC's INTENSET register. 

    Usually, this register is configured by the RTC driver, depending on what config parameters it was given during set-up. See f.ex. nrfx_rtc_cc_set and its enable_irq parameter. 

Related