BLE SDH observer interrupt level

We are using SDK15.0.0 and have products with both the NRF52832 and NRF52840 sharing the vast majority of code between them. The softdevices we use are S132 and S140 at version 6.0.0

We have a BLE event handler registered as an observer as follows:

NRF_SDH_BLE_OBSERVER(m_ble_observer, 2, ble_evt_handler, NULL);

Within the event handler we enqueue events into our own event queue that is interrupt level aware. We are observing that on the NRF52832 (using S132) the observer is reporting events  on interrupt level 7 while for the NRF52840 this is interrupt level 6.

My questions are thus:

1) Is this difference in behaviour intentional? If not what might be the factors involved in determining the interrupt priority?

2) Is there a recommended/official way to configure the interrupt level these events will come from?

I have had a look through both the official documentation and the sdk_config.h file, and found no clear way of setting the interrupt level for the observers. There is a fair bit about the observer priorities but from my understanding this is a totally separate thing to the interrupt level. In addition, I have not found anything particularly clear in the documentation regarding what interrupt level the observers will be notified on.

Any help would be much appreciated

  • Hi,

    You are right that there are different interrupt priorities for the SD_EVT SWI between some SoftDevices, and there was also a mismatch with what was used by the SoftDevice and what was documented in the SoftDevice specification (this was a bug). In SDK 15.0.0 there is code manipulating this in swi_interrupt_priority_workaround() in <SDK15.0.0>\components\softdevice\common\nrf_sdh.c for all SoftDevices except S140, which sets the priority to 7. This was changed in SDK 15.2, and you can find a brief mention of it in the release notes:

    Removed the workaround in nrf_sdh.c overriding the default priority level on SWI interrupt SD_EVT_IRQn and RADIO_NOTIFICATION_IRQn used by the SoftDevice.

    The SoftDevice priority is 6, and that is intentional. This is also mentioned in the release notes of SoftDevice S132 6.1.0:

    Fixed documentation for SD_EVT_IRQHandler and RADIO_NOTIFICATION_IRQHandler, where the default interrupt priority was documented incorrectly (DRGN-10174).

    So, for the questions:

    1) Is this difference in behaviour intentional? If not what might be the factors involved in determining the interrupt priority?

    No. It was a bug. The priority should have been 6.

    2) Is there a recommended/official way to configure the interrupt level these events will come from?

    You can use sd_nvic_SetPriority() to change the interrupt priorities of the SoftDevice, as done in the implementation of swi_interrupt_priority_workaround(). This is not normally something you should do with the SoftDevice interrupts, though

Related