Lowest power while keeping app timers running

I have an app running the S132 softdevice, doing most of the applicatino work in a routine being called by an 8 Hz app-timer. Under certain conditions that I detect with external hardware, I need to achieve the lowest possible power consumption and turn the radio off. However, if I just stop the softdevice I also lose the timer. I apparently do not have the right search terms as I'm sure this has been asked before. I need to shut down everything else, and ideally just leave the app timer running, even at a slower (but known and fixed) rate.

Or am I asking too much from the softdevice, and should just shut it down altogether and go straight to a bare hardware timer implementation using the RTC with LFCLK?

Parents
  • Hello,

    It is sufficient to stop any ongoing bluetooth activities (such as stopping the advertiser or terminating an active connection). It's not necessary to disable the softdevice as it won't affect the idle current. 

    Best regards,

    Vidar

  • Is nrf_sdh_suspend () the correct function to use here, to stop all BLE activities?

  • There isn't a single function to stop all BLE activities. Is the device always advertising before entering this low power mode, or could it also be in a connection? nrf_sdh_suspend() disables the SoftDevice IRQ which is not what you want in this case.

  • If I understand correctly, disabling the IRQ will also disable my app timer, which needs to keep running to determine when to wake everything back up. It is possible a connection will be active, so what function is the correct one to call to shut down the connection, and what function to stop advertising?

  • The app timer runs independently of the softdevice and they do not share the same IRQ. However, it will stop running if the LFCLK is released when disabling the softdevice (which can happen if you use nrf_sdh_disable_request()).

    You can try using the function below to stop BLE activity before entering the low power mode.

    static void ble_stop(void)
    {
        /* 
         * The default behavior when using the Advertising module is that the
         * advertiser will automatically restart on disconnect, but here
         * we need the advertiser to remain disabled. To acheive this we can set the
         * ble_adv_on_disconnect_disabled flag to 'true' in the advertiser configuration.
         * 
         * Important: Remember to reset this flag when exiting low power mode to restore
         *            default behaviour.
         *
         * https://docs.nordicsemi.com/bundle/sdk_nrf5_v17.1.0/page/lib_ble_advertising.html 
         */
        m_advertising.adv_modes_config.ble_adv_on_disconnect_disabled = true;
    
        (void)sd_ble_gap_adv_stop(0);
        (void)sd_ble_gap_disconnect(0, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
    }
    

Reply
  • The app timer runs independently of the softdevice and they do not share the same IRQ. However, it will stop running if the LFCLK is released when disabling the softdevice (which can happen if you use nrf_sdh_disable_request()).

    You can try using the function below to stop BLE activity before entering the low power mode.

    static void ble_stop(void)
    {
        /* 
         * The default behavior when using the Advertising module is that the
         * advertiser will automatically restart on disconnect, but here
         * we need the advertiser to remain disabled. To acheive this we can set the
         * ble_adv_on_disconnect_disabled flag to 'true' in the advertiser configuration.
         * 
         * Important: Remember to reset this flag when exiting low power mode to restore
         *            default behaviour.
         *
         * https://docs.nordicsemi.com/bundle/sdk_nrf5_v17.1.0/page/lib_ble_advertising.html 
         */
        m_advertising.adv_modes_config.ble_adv_on_disconnect_disabled = true;
    
        (void)sd_ble_gap_adv_stop(0);
        (void)sd_ble_gap_disconnect(0, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
    }
    

Children
No Data
Related