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

Sequential multiprotocol: use nrf_nvic_ functions only when Softdevice is enabled?

When the Softdevice is not enabled, can the nrf_nvic_ functions be used? When I never enable Softdevice but call err_code = sd_nvic_ClearPendingIRQ(RADIO_IRQn) I get error code x2001, NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE. Which leads me to believe that I can't use those functions when the Softdevice is not in the enabled state. The context is that I am attempting sequential multiprotocol, during startup I want to use the radio for my proprietary protocol, and later enable the Softdevice and use BLE. Previously I was using the CMSIS NVIC_ functions during my proprietary protocol, and it seemd to work. When I switched to the nrv_nvic_ functions, I got this error.

The Softdevice spec says "Once the SoftDevice has been enabled, more restrictions apply: .... nrf_nvic_ functions must be used instead of CMSIS NVIC_ functions for safe use of the SoftDevice." That doesn't say that the functions cannot be used when the Softdevice is in the disabled state. Maybe I need to init() the Softdevice without enabling it?

That is also fuzzy. Does "Once the SoftDevice has been enabled" mean: "if you have ever enabled the SoftDevice", or does it mean "when the SoftDevice is in the enabled state"? As technical writing, use of the passive tense "has been enabled" is what smells bad.

SDK v14.2 S132 v5.0.1 NRF52

  • Hi,

    You need to use the non-sd nvic functions when the SoftDevice is not enabled. The sd_nvic_*() functions will check if you are accessing any of the restricted/blocked peripherals, and return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE if you are. So instead of sd_nvic_ClearPendingIRQ(), you should use NVIC_ClearPendingIRQ() if you have not enabled the SoftDevice. With the SoftDevice handler library in SDK 14.2, you can check if the SoftDevice is enabled or not with the function nrf_sdh_is_enabled(). The restrictions listed under "Once the SoftDevice has been enabled, more restrictions apply" should be lifted once you completely disable the SoftDevice with the nrf_sdh_disable_request() function.

Related