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

What is the easiest way to disable all interrupts?

Using the nRF51822. I have a routine that should never be interrupted. What is the easiest way to disable all interrupts, and then re-enabling them?

Parents
  • There is no way to disable all interrupts as long as the softdevice is enabled, since this will possibly make you lose the BLE connection.

    You can however disable all application interrupts by using sd_nvic_critical_region_enter()/_exit() functions.

    Edit: If however the softdevice is disabled, or it's ok for your application to risk getting asserts back from the softdevice, you can use the CMSIS functions __disable_irq() and __enable_irq() to achieve this. Be aware that if you do this while in a connection or while advertising, you will get asserts if you're unlucky with the timing. This problem can be reduced (and possibly avoided) by using the radio notification feature to control when exactly you do this, but this is anyway not something we recommend to do.

Reply
  • There is no way to disable all interrupts as long as the softdevice is enabled, since this will possibly make you lose the BLE connection.

    You can however disable all application interrupts by using sd_nvic_critical_region_enter()/_exit() functions.

    Edit: If however the softdevice is disabled, or it's ok for your application to risk getting asserts back from the softdevice, you can use the CMSIS functions __disable_irq() and __enable_irq() to achieve this. Be aware that if you do this while in a connection or while advertising, you will get asserts if you're unlucky with the timing. This problem can be reduced (and possibly avoided) by using the radio notification feature to control when exactly you do this, but this is anyway not something we recommend to do.

Children
No Data
Related