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

NVIC_EnableIRQ vs sd_nvic_EnableIRQ

I have an application that uses the soft device and RTX RTOS. I am seeing a behavior I can't explain. I use sd_app_evt_wait() in the idle thread after I have turned off power to the peripherals in use and set up GPIOTE PORT event to wake it up from sleep state. I have also implemented the handler for the GPIOTE which will restore power to the peripherals. For this test, I used one of the GPIO lines to initiate sleep mode. In the on state, I have some LEDs that blink. Once in sleep state, it turns off the LEDs and remains in low power state but still handles BLE activities. I can read and write to the device using MCP while in sleep state.

The GPIOTE event /interrupt isn't used when in on state. It is configured and the interrupt enabled just before sleep mode entry. The problem I see is that sd_nvic_EnableIRQ(GPIOTE_IRQn) doesn't seem to enable the interrupt operation. I have set breakpoints in the handler and can see the GPIOTE->EVENT_PORT going active when the configured button is pressed, but the handler is never called. But when NVIC_EnableIRQ() is used instead, it functions as expected. I have two questions related to this.

  1. Why is the sd_nvic_EnableIRQ() not working?
  2. Why is the NVIC_EnableIRQ() working? I would have thought it would misbehave when this fuction is called while the soft device is enabled.

Also, once it is in low powr mode, I am seeing 910uA current when it isn't connected to a client and 1.2mA when connected. What am I missing that is causing this much current?

Regards, Daniel

Parents
  • Hi Daniel

    1. By default the interrupt priority of all interrupts is set to 0, which is reserved exclusively for the SoftDevice. Please try setting the interrupt priority to 1 or 3 using sd_nvic_SetPriority(..) before you enable it, then it should work.

    2. Because the NVIC peripheral is included in the Cortex M0 core the MPU is not able to apply the same protection mechanisms to the NVIC as it can to all other peripherals. For this reason it is possible to call the NVIC even when the SoftDevice is running. That said you should use the sd_nvic_ API instead to be sure that you are not using the interrupts wrong, or the SoftDevice might become unstable.

    Why the current consumption is so high in connected mode I am not sure. Are you turning on any particular peripherals/modules after a connection is established? Are there any LED's or other hardware that is drawing current?

    Best regards Torbjørn

  • Yep, sd_nvic_SetPriority did the trick for me too.

Reply Children
No Data
Related