11.07.2015 Views

IAR PowerPac RTOS User Guide

IAR PowerPac RTOS User Guide

IAR PowerPac RTOS User Guide

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

InterruptsNesting interrupt routinesBy default, interrupts are disabled in an ISR because the CPU disables interrupts with the execution of the interrupthandler. Re-enabling interrupts in an interrupt handler allows the execution of further interrupts with equal or higherpriority than that of the current interrupt. These are known as nested interrupts, illustrated in the diagram below:Task ISR 1 ISR 2 ISR 3Interrupt 1Interrupt 2Interrupt 3TimeFor applications requiring short interrupt latency, you may re-enable interrupts inside an ISR by usingOS_EnterNestableInterrupt() and OS_LeaveNestableInterrupt() within the interrupt handler.Nested interrupts can lead to problems that are difficult to track; therefore it is not really recommended to enableinterrupts within an interrupt handler. As it is important that <strong>IAR</strong> <strong>PowerPac</strong> <strong>RTOS</strong> keeps track of the status of theinterrupt enable/disable flag, the enabling and disabling of interrupts from within an ISR has to be done using thefunctions that <strong>IAR</strong> <strong>PowerPac</strong> <strong>RTOS</strong> offers for this purpose.The routine OS_EnterNestableInterrupt() enables interrupts within an ISR and prevents further task switches;OS_LeaveNestableInterrupt() disables interrupts right before ending the interrupt routine again, thus restores thedefault condition. Re-enabling interrupts will make it possible for an <strong>IAR</strong> <strong>PowerPac</strong> <strong>RTOS</strong> scheduler interrupt toshortly interrupt this ISR. In this case, <strong>IAR</strong> <strong>PowerPac</strong> <strong>RTOS</strong> needs to know that another ISR is still active and that itmay not perform a task switch.OS_EnterNestableInterrupt()DescriptionRe-enables interrupts and increments the <strong>IAR</strong> <strong>PowerPac</strong> <strong>RTOS</strong> internal critical region counter, thus disabling furthertask switches.Prototypevoid OS_EnterNestableInterrupt (void);Additional InformationThis function should be the first call inside an interrupt handler when nested interrupts are required. The functionOS_EnterNestableInterrupt() is implemented as a macro and offers the same functionality asOS_EnterInterrupt() in combination with OS_DecRI(), but is more efficient, resulting in smaller and faster code.ExampleRefer to the example for OS_LeaveNestableInterrupt().PP<strong>RTOS</strong>-2105

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!