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

GPIOTE interrupt and BLE send resulting in hard fault

Hi ,

I am trying to set up event using GPIOTE. I want to implement reading of sensor data and sending over BLE when an interrupt is generated due to activity on a particular pin. I am following pin_change_int_example code and changed just the pin number from 0 to the pin that i want to see transition from high to low. I am able to get interrupt and GPIOTE_IRQHandler is getting called , but when I try to send some data over bluetooth using softdevice function calls in the interrupt handler, device goes into HardFault. And one other thing observed is once we initialize the GPIOTE , I am getting lot of interrupts (which is expected due to fast transitions happening on the pin for which the interrupt event is registered) but main thread or timer threads are never getting called due to this . Can you please help resolve the issues and how can i implement my requirement.

  • This is discussed often, a search would have thrown up a number of answers.

    What interrupt priority is your GPIOTE IRQ? If it's APP HI then it's above the priority in which the softdevice service calls run and you can't call a lower priority interrupt from a higher priority one, you get a hardfault.

    Run your GPIOTE IRQ in APP LO priority if you want to call the softdevice directly. Or find a way to have the GPIOTE handler set up a call which is handled by a lower priority interrupt or the main context later.

  • You need to setup app_scheduler and call app_sched_event_put(...) within the GPIOTE_IRQ handler to transfer the event handling to the app_scheduler. From the app_scheduler event handling you can call any Softdevice function.

Related