Electronic – Interrupt Priorities- What does it actually mean

interrupts

I have one generic question regarding interrupts. My software has 2 interrupts,lets say interrupt_x (timer), interrupt_y(spi).

Both interrupt has its own ISR. Interrupt_x has higher priority than interrupt_y. What does assigning priorities actually means? Does it means that Interrupt_x and interrupt_y will actually interrupt the core when it is supposed to, but the corresponding ISR will only execute based on their priority? Or does it means interrupt_x will prevent interrupt_y to interrupt the core when both interrupts happen together, because interrupt_x has higher priority and because of that their ISR is executed accordingly? The CPU is RL78/G14

Best Answer

A priority interrupt controller has certain basic functionality that virtually all of this type share (as noted, certain specifics vary by device).

An example of one type might be useful.

Let's say I have a priority controller with 3 levels, A, B and C and that the priority order is A highest, B next, C lowest and each has been assigned to a particular event (timers perhaps, maybe a pin state change)

What could conceivably happen is this:

Interrupt C occurs; as there is currently no other interrupt pending, the interrupt vector is taken.

Before the interrupt handler for C completes, interrupt A occurs; the interrupt handler for C is suspended and the interrupt vector for interrupt A is taken (because interrupt A has a higher priority).

Prior to the interrupt handler for A finishing, interrupt B occurs; the interrupt handler for interrupt A continues (because B has a lower priority) until it completes and execution returns to the interrupt C handler (because that is where the processor was when interrupt A occurred).

The interrupt vector is immediately taken for interrupt B (because it has a higher priority than interrupt C) and completes the handler.

Execution now returns to interrupt C handler which can now complete (assuming neither of the other two interrupts happen in that time).

This is but one type of controller architecture, but it might give you the flavour of what these things do.