Embedded Systems & Firmware
On a microcontroller with interrupt priorities, a higher-priority interrupt occurs while a lower-priority handler is running. What generally happens (assuming nesting is allowed)?
- AThe low-priority handler is suspended, the high-priority handler runs, and then the low one resumes
- BThe high-priority interrupt is discarded until the low handler finishes
- CBoth handlers execute in parallel on the same CPU at once
Show answer and explanation
Answer: A. The low-priority handler is suspended, the high-priority handler runs, and then the low one resumes
With interrupt priorities, an urgent interrupt is serviced even while another handler is running. For example, if motor overcurrent detection has high priority and communication reception low priority, overcurrent can be handled at once even mid-reception. Arm Cortex-M's NVIC and others provide this mechanism. Interrupts of equal or lower priority wait until the current handler finishes.
- A. Correct. This is called interrupt nesting.
- B. It is serviced immediately, not discarded.
- C. One CPU executes one thing at a time.