This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
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

BLE RADIO ON/OFF in interrupt handler

Hi, Am using NRF52 S132 softdevice, I have a use case like when I press a button , I should turn off BLE. So I enabled an interrupt for button. Whenever this button is pressed in the interrupt handler I called sd_ble_gap_adv_stop(); but it hanged .. Cant we call any softdevice related function in interrupt handler ?

Parents
  • What's the priority of the button interrupt? If it's high then it's higher than the SVC call priority and the ARM Cortex will hardfault. It needs to be low if you want to call sd_* functions from it.

    If it's that - this is discussed at least 5 times a week, a quick search would have answered the question; if it's not, then it didn't "hanged", there's an error or a hardfault, hit the break button and find out where you are and update the question with more information.

Reply
  • What's the priority of the button interrupt? If it's high then it's higher than the SVC call priority and the ARM Cortex will hardfault. It needs to be low if you want to call sd_* functions from it.

    If it's that - this is discussed at least 5 times a week, a quick search would have answered the question; if it's not, then it didn't "hanged", there's an error or a hardfault, hit the break button and find out where you are and update the question with more information.

Children
  • Hi RK Thanks for your reply and sorry for the delay in my response.. Yes as you said My GPIO interrupt and the ble satck interrupt are of same priority, but when I try to change the priority as per your suggestion my code is keep on rebooting .. What I want to do is this -> In my ble_app_uart eaxample I need to send data to the another device via BLE whenever a button is pressed.

  • post the code where you change the GPIO interrupt priority

  • My SVC call priority is 3 (APP_IRQ_PRIORITY_LOW)

    void gpio_interrupt_init(void) { /-------------------------- INTERRUPT MODE ------------------------------------------/ NRF_GPIOTE->CONFIG[1] = (GPIOTE_CONFIG_POLARITY_HiToLo << GPIOTE_CONFIG_POLARITY_Pos) | (BUTTON_1 << GPIOTE_CONFIG_PSEL_Pos) | (GPIOTE_CONFIG_MODE_Event << GPIOTE_CONFIG_MODE_Pos); NRF_GPIOTE->INTENCLR = GPIOTE_IRQ_INTENCLR_ALL_VAL; NRF_GPIOTE->INTENSET = (GPIOTE_INTENSET_IN1_Set << GPIOTE_INTENSET_IN1_Pos); NVIC_SetPriority(GPIOTE_IRQn, 4); NVIC_EnableIRQ(GPIOTE_IRQn); }

  • Nothing much right there. Firstly priority 3 isn't APP_IRQ_PRIORITY_LOW, that's the nRF51, low on the nRF52 is 6 and lowest is 7. Secondly the only priorities available to the app are 2, 3, 6 and 7 so you can't use 4 and finally the SVC priority is 4, defined by the softdevice itself. So you've actually just set the priority to the same as the SVC call one and you are still hardfaulting. Change it to a proper low value like 6.

  • Hi RK Sorry, I have both NRF51 and NRF52 with me, with NRF52 it was working when I set the priority to lowest priority but not with NRF51 . How can I get it working in NRF51

Related