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

Does the NVIC really do interrupt nesting?

Note: This was originally posted on 23rd February 2011 at http://forums.arm.com

For days I've been banging my head with a problem that shouldn't take more than a minute time otherwise. How to get the NVIC of Cortex M3 handle the simplest in the world interrupt nesting - an interrupt within interrupt.
In details - I have the SysTick running that executes my handling function. What I am trying to achieve is to re-enable the SysTick interrupt and let the same function be executed should another SysTick has occured while it was still serving the previous one. With the old "dumb" ARM7's VIC that was the easiest thing to do - just enabling the interrupts again once I've entered my function. But with this "advanced" one, a person apparently has to go through some tricks to get the job done.
Any help would be warmly welcome!
Thanks
  • Note: This was originally posted on 24th February 2011 at http://forums.arm.com


    I can't even say whether you could trick the NVIC into doing anything like this, since I have never been in a situation where this seemed to be the best solution. Could you describe a scenario where this would be necessary?

    Regards
    Marcus



    Sure. I am porting my own in-house RTOS kernel that uses task scheduling based on stacking. It has been working great for years on the old ARM7 machines and many other CPUs, even some PICs. Having an interrupt within interrupt is among the simplest things a modern CPU could do. The whole story develops around the fact I can execute the stack from within itself with the currently pending tasks. I take care myself about the stack overflow but I simply need the ability to re-enable the same interrupt and let it be served while I am still in it.
    CM3 is the first CPU I've ever sen that seems to disable this functionality but I really hope someone will prove me wrong as I am very much a noob with this one.
  • Note: This was originally posted on 25th February 2011 at http://forums.arm.com

    Thanks for the responses. I can't believe that's true! So bad... The Cortex family has lost me forever. NVIC is a disaster!
  • Note: This was originally posted on 24th February 2011 at http://forums.arm.com

    NVIC supports nested interrupts, but the nesting can only occur if the new interrupt has higher priority than the executing one. Also, Cortex-M3 does not allow reentrant of interrupt (if a interrupt is already in active state, it cannot enter it again until the active status is cleared.)

    Your question has been asked before in various forums, some pointers here:
    http://forums.arm.com/index.php?/topic/14393-reentrant-interrupt-on-systick-with-the-cortex-m3/
    http://forums.arm.com/index.php?/topic/12745-abort-some-questions-of-arm-interrupt/
    http://e2e.ti.com/support/microcontrollers/stellaris_arm_cortex-m3_microcontroller/f/471/p/59877/220223.aspx?PageIndex=2

    Google for reentrant interrupt on Cortex-M3 you can find more.
  • Note: This was originally posted on 24th February 2011 at http://forums.arm.com


    What I am trying to achieve is to re-enable the SysTick interrupt and let the same function be executed should another SysTick has occured while it was still serving the previous one.

    I can't even say whether you could trick the NVIC into doing anything like this, since I have never been in a situation where this seemed to be the best solution. Could you describe a scenario where this would be necessary?

    Regards
    Marcus
  • Note: This was originally posted on 24th February 2011 at http://forums.arm.com


    I am porting my own in-house RTOS kernel that uses task scheduling based on stacking.

    I see. Do you have any reference where this mechanism might be explained? Perhaps it could be implemented on Cortex-M3 without having to remain in the ISR.

    Simply changing (lowering in your case) the current execution priority in Cortex-M3 can only drop down to the priority of the highest priority preempted exception. So that wouldn't work in your situation I am afraid.


    It has been working great for years on the old ARM7 machines

    Since then you may have forgotten how painful it was to get nested/reentrant interrupts working on ARM7 in the first place :-)


    The whole story develops around the fact I can execute the stack from within itself with the currently pending tasks. I take care myself about the stack overflow but I simply need the ability to re-enable the same interrupt and let it be served while I am still in it.

    Sounds interesting but also scary. Again, would you have any references?

    Regards
    Marcus