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

Softdevice S140 and SWI2 interrupt handing

Hey

I'm using the softdevice s140 in my project (and the latest SDK 17.x).

I successfully enable the softdevice and am able to start an advertising (as peripheral). However when I try to connect to it via a central device the connection times out. When I debug I see that the SWI2 is triggered (I've added a default irg handler), but my BLE-Event handler which I registered like this:

NRF_SDH_BLE_OBSERVER(m_ble_observer, BLE_OBSERVER_PRIO, vHandleBleEvent, NULL);

gets never called.

Now my questions:

- Why is SWI triggered?

- How can I get the SD to trigger the registered BLE event handler (vHandleBleEvent) ?

Any help would be much appreciated.

Cheers

David

UPDATE:

I've had a look at the SD_EVT_IRQHandler defined in nrf_sdh.c and implemented my own IRQ handler for SWI2 where I call the same function, which is called in SD_EVT_IRQHandler.

void vSwi2IRQHandler(void)
{
    nrf_sdh_evts_poll();
}

Now I receive BLE events via the registered ble-event handler, which is great, because now I can establish a BLE connection.

So this issue is more or less solved, however I still am wondering, if there is something wrong with my code.

This question remains:  Is it OK to define my own irq handler for SWI2 and poll for events there? Is it safe, or could it lead to unexpected behavior?

Parents
  • Hello,

    I would recommand that you use the SoftDevice Handler library (nrf_sdh.c, nrf_sdh_ble.c, nrf_sdh_soc.c ) like in our BLE example instead of polling and propagating the events yourself. The main problem with declaring your own SD_EVT_IRQHandler is that you will have implement a mechanism to forward SoC and BLE events to other SDK modules.

    Best regards,

    Vidar

  • Thanks for your answer. I agree with your suggestion to use the SoftDevice Hanlder library, however I could not get it to work. Now I've found out, that our application overwrites the vector-table and I forgot to add the correct irq-handler (provided by nrf_soh.h) to the SWI2. Now, after configuring it correctly it works perfectly.

Reply
  • Thanks for your answer. I agree with your suggestion to use the SoftDevice Hanlder library, however I could not get it to work. Now I've found out, that our application overwrites the vector-table and I forgot to add the correct irq-handler (provided by nrf_soh.h) to the SWI2. Now, after configuring it correctly it works perfectly.

Children
No Data
Related