This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

priority of NRF_SDH_BLE_OBSERVER()

Hi,

I use ble_app_uart sample code using nRF52840 in SDK15.

There is a code below in ble_stack_init().

NRF_SDH_BLE_OBSERVER(m_ble_observer, APP_BLE_OBSERVER_PRIO, ble_evt_handler, NULL);

And APP_BLE_OBSERVER_PRIO is defined as 3 at the top.

On the other hand, nordic document tells that softdevice API uses priority 4 interrupt handler in nRF52,

and also tells that user must call softdevice API with lower priority than 4.

And there is softdevice API call inside ble_evt_handler() and works perfectly(for example, sd_ble_gap_disconnect()).

So I think NRF_SDH_BLE_OBSERVER priority does not indicate interrupt priority.

Is this correct?

If it is correct, what does NRF_SDH_BLE_OBSERVER priority means?

  • Hello kazuo,

    Thanks for your question.

    NRF_SDH_BLE_OBSERVER(m_ble_observer, APP_BLE_OBSERVER_PRIO, ble_evt_handler, NULL); here APP_BLE_OBSERVER_PRIO is the parameter inside this NRF_SDH_BLE_OBSERVER function. The value of this parameter is input to the NRF_SDH_BLE_OBSERVER() function and the value of this priority observer adds NRF_SDH_BLE_OBSERVER to a list. The priority here defines the location in the list (see API documentation for NRF_SECTION_SET_ITEM_REGISTER in components\libraries\experimental_section_vars\nrf_section_iter.h). 

    #define NRF_SECTION_SET_ITEM_REGISTER(_name, _priority, _var)                                       
        NRF_SECTION_ITEM_REGISTER(CONCAT_2(_name, _priority), _var)
      (The order of the section in the set is based on the priority. The order with which variables are placed in a section is dependent on the order with which the linker encounters the variables during linking.
       name:       Name of the section set.
      priority:   Priority of the desired section.
      var        The variable to register in the given section.)
     

    The SDH module iterates this list and calls the high priority callback first. Then the lower priority. All are called with same interrupt priority which is 4 (SoftDevice API calls and non-time-critical processing)  in this case. 

    So, we can say that we define the order to run the callback functions from a list where the order will run with interrupt priority 4. 

     I hope it helps. Just let me know if it is not clear. 

    Best Regards,

    Kazi Afroza Sultana

Related