4

I have started using ARM Cortex M0+ for GPIO Interrupts. I want to disable nesting feature from ARM Interrupts. Is there any way to do it.? I know by default, nesting is enabled in ARM, I want to disable it.

anandamu16
  • 103
  • 1
  • 2
  • 9
  • 1
    Please read this [thread](https://community.arm.com/processors/f/discussions/2683/changing-interrupt-priority-to-prevent-nesting) on ARM community website. May be this is what you need! – Gaurav Pathak Aug 21 '17 at 07:22
  • @anandamu16: Can you elaborate on why you need this feature? You can of course always disable interrupt nesting simply by not using multiple priority levels. The M0+ lacks Cortex M3-style configurable sub-priorities however if you require priority arbitration up to but not including interrupt entry. It is difficult to help you without knowing the particular requirements. To be honest sub-priority masking is somewhat esoteric and should not normally be required unless shaving off the last very cycles of latency, in which case I suggest reconsidering using full preemption. – doynax Aug 21 '17 at 07:41
  • @Doynax: Actually I was recently working on Gpio Level Triggered Interrupts. But it was giving me multiple interrupts as soon as push button was pressed (This was because multiple interrupts occur within the time button press completed). I want to have interrupt only once till Gpio Handler exection gets completed. Also I don't want to disable GPIO Interrupt. Moreover, am I right that by default nesting is Enabled in ARM Cortex M0+ Interrupts? – anandamu16 Aug 21 '17 at 09:36
  • Thanks Gaurav for the reference, I will check the link – anandamu16 Aug 21 '17 at 09:38
  • 1
    @anandamu16: I am still not following you I'm afraid. A single interrupt handler never preempts itself on the Cortex `M0+` without some significant contortions. Multiple different interrupt handlers, say on two GPIO ports, may preempt each other if the preempting interrupt source has been set to a higher priority. By default are all configured for the same priority level however and so this should not happen unless you've opted in. – doynax Aug 21 '17 at 11:02
  • how did you debounce your button? mechanical buttons in general give many interrupts, simple physics. interrupts or polling you still have to deal with determining what the user thinks the state of the button is. – old_timer Aug 21 '17 at 13:48
  • @anandamu16 : your issue with level-triggered interrupts is a different question; perhaps you should ask about that. Looks like an XY problem; you think non-nestable interrupts is the solution to your problem, so you are asking about that instead of asking about the real problem. The solution in that case is perhaps to use edge triggering, otherwise the interrupt will be invoked repeatedly so long as the level persists - it is not reentering or nesting, it is repeatedly running to completion. Another solution is to switch the trigger level. Neither method will debounce the switch however. – Clifford Aug 22 '17 at 02:05

1 Answers1

4

ARM Cortex-M0/M0+ do not support interrupt priority grouping into preemption priority(nestable) and sub-priority (non-nestable) available on the M3/M4/M7 for example.

If you wish to prevent interrupt nesting; it would be necessary to either;

  • set all interrupts to the same priority, or
  • disable and re-enable interrupts on entry and exit to all handlers.

The first of these options is the simplest, but gives no control over execution order (which seldom matters for asynchronous events, but may lead to non-deterministic behaviour and timing). The second does not actually prevent nesting, but does allow nesting only before the lower-priority interrupt has disabled the interrupts - before it has started processing the actual event. The result is behaviour similar to that of sub-priorities available on Cortex-M3 etc.

Clifford
  • 88,407
  • 13
  • 85
  • 165
  • Note this is an answer to the question, not a solution to the problem described subsequently in the comments. It appears ot be an XY Problem question. – Clifford Aug 22 '17 at 02:06