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

TASKS_CONSTLAT with S112

Hello,

My application is the ble_app_uart example of SDK 15.3 extended, and using S112. I'd like to use constant latency mode. Given the app uses S112 for BLE, should I call:

sd_power_mode_set(NRF_POWER_MODE_CONSTLAT);

instead of:

NRF_POWER->TASKS_CONSTLAT = 1;

Also, at what point should I turn constant latency on? After all initialization (ble_stack_init(), gap_params_init(), gatt_init(), services_init(), etc.)?

Thank you,

Tim

Parents
  • Hello Tim,

    Yes, you should call sd_power_mode_set() if you want to change the power mode while the Softdevice is enabled, because POWER is one of the peripherals which the Softdevice reserves access to (Hardware peripherals). Sub-power modes can be changed dynamically, so it's not important when you make the call, but I think it's more fitting to do it at the end of  the ble_stack_init() routine than inside the other functions you mentioned.

    Also, it may be worth noting that the S112 does not sandbox reserved peripherals with the Memory watch Unit (MWU) like the s132, so you will not be prevented from writing directly  to the NRF_POWER register (s132 - Memory isolation and runtime protection).

    Best regards,

    Vidar

  • Thank you Vidar. I've modified my initialization code to be this:

    ret_code_t err_code;

    timers_init();
    power_management_init();
    ble_stack_init();

    err_code = sd_power_mode_set(NRF_POWER_MODE_CONSTLAT);
    APP_ERROR_CHECK(err_code);

    adc_configure();
    gap_params_init();
    gatt_init();
    services_init();
    advertising_init();
    conn_params_init();
    .
    .
    .

    Correct?

    From this post, I understand that by invoking constant latency mode, the HF clock will always be on, which is required for my application. However, if I test following the call to sd_power_mode_set(NRF_POWER_MODE_CONSTLAT), it appears HF clock is not running. The while loop in the code below never exits.

    ble_stack_init();

    err_code = sd_power_mode_set(NRF_POWER_MODE_CONSTLAT);
    APP_ERROR_CHECK(err_code);

    uint32_t is_running;
    do {
    sd_clock_hfclk_is_running(&is_running);
    } while (is_running==0);

    adc_configure();
    gap_params_init();
    .
    .

    If I add a call to sd_clock_hfclk_request(), prior to the while loop, the loop will exit and HF clock runs. Certainly I can leave in the call to sd_clock_hfclk_request(), but would like to be sure sd_power_mode_set(NRF_POWER_MODE_CONSTLAT) is functioning as expected.

    Thanks,

    Tim

  • Yes, it will work as long as you call it after ble_stack_init().

    It's correct that constant latency mode keeps the HF clock on. But there are two different  HF clock sources that the system can use, and the sd_clock_hfclk_is_running() function is checking if the more accurate 64 MHz crystal oscillator (HFXO) source is active. The less accurate HFINT source is used if it returns false.

    Best regards,

    Vidar

Reply Children
No Data
Related