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

SOFTDEVICE_PRESENT versus sd_softdevice_is_enabled()

Hello -

We are developing some low power code on the nRF52840-DK, using SDK 15.3.0 on FreeRTOS. I noticed that in the port_cmsys_systick.c file, in the vPortSuppressTicksAndSleep() function, that the code just checks if SOFTDEVICE_PRESENT is defined before calling a SoftDevice function:

#ifdef SOFTDEVICE_PRESENT

        uint32_t err_code = sd_app_evt_wait();
        APP_ERROR_CHECK(err_code);
#else

In our case, we currently enable the SoftDevice when requiring BLE, but otherwise we do not request that the SoftDevice is enabled. In other words, we only call nrf_sdh_enable_request() when using BLE. We do however have SOFTDEVICE_PRESENT defined in our Makefile.

I am wondering if the port_cmsys_systick.c code is correct when the application does not have a SoftDevice enabled. At first glance it seems that defining SOFTDEVICE_PRESET implicitly assumes that the SoftDevice has been enabled, which may not be the case.

Regards,

Brian

Parents
  • Hello -

    Thank you for the quick follow-up. In the v16.0.0 code, I see that sd_nvic_critical_region_enter() and sd_nvic_critical_region_exit() also seem to have the same issue:

    #ifdef SOFTDEVICE_PRESENT
    do{
    uint8_t dummy = 0;
    uint32_t err_code = sd_nvic_critical_region_enter(&dummy);
    APP_ERROR_CHECK(err_code);
    }while (0);
    #else
    __disable_irq();
    #endif
    

    Is it okay to call sd_nvic_critical_region_enter() and sd_nvic_critical_region_exit() when the SoftDevice is not enabled?

    Regards,

    Brian

Reply
  • Hello -

    Thank you for the quick follow-up. In the v16.0.0 code, I see that sd_nvic_critical_region_enter() and sd_nvic_critical_region_exit() also seem to have the same issue:

    #ifdef SOFTDEVICE_PRESENT
    do{
    uint8_t dummy = 0;
    uint32_t err_code = sd_nvic_critical_region_enter(&dummy);
    APP_ERROR_CHECK(err_code);
    }while (0);
    #else
    __disable_irq();
    #endif
    

    Is it okay to call sd_nvic_critical_region_enter() and sd_nvic_critical_region_exit() when the SoftDevice is not enabled?

    Regards,

    Brian

Children
Related