SoC
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
  • Arm Cortex M3
  • Contact
Reading: Which interrupt has the highest priority in arm?
SUBSCRIBE
SoCSoC
Font ResizerAa
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
Search
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
Have an existing account? Sign In
Follow US
  • Looking for Something?
  • Privacy Policy
  • About Us
  • Sitemap
  • Contact Us
© S-O-C.ORG, All Rights Reserved.
Arm

Which interrupt has the highest priority in arm?

Holly Lindsey
Last updated: September 15, 2023 11:57 am
Holly Lindsey 6 Min Read
Share
SHARE

In the ARM architecture, interrupts are handled by the processor’s interrupt controller and vectored interrupt controller. The interrupt controller receives interrupt requests from various sources and determines the priority of the interrupts. The vectored interrupt controller uses the priority to determine which interrupt should be handled first when multiple interrupts are pending.

Contents
Default Highest Priority InterruptChanging Interrupt PrioritiesNested InterruptsPriority Level GroupsManaging Interrupt LatencyUse CasesConclusion

ARM processors typically support up to 256 interrupt requests or IRQs numbered from 0 to 255. Lower numbered IRQs generally have higher priority than higher numbered IRQs. For example, IRQ 0 has the highest priority while IRQ 255 has the lowest priority. However, the exact priority levels can be configured by programming the priority registers in the interrupt controller.

Default Highest Priority Interrupt

By default, without any priority configuration, IRQ 0 has the highest priority in ARM processors. This IRQ is usually reserved for the system timer interrupt. The system timer generates periodic interrupts for task scheduling and timekeeping. Giving it the highest priority ensures timer events are handled promptly for real-time performance.

Other common high priority interrupts in ARM include:

  • IRQ 1 – Keyboard interrupt
  • IRQ 2 – Cascade interrupt for secondary interrupt controller
  • IRQ 3 – UART interrupt for serial ports
  • IRQ 4 – UART interrupt for serial ports
  • IRQ 5 – GPIO interrupt for external signals

These interrupts need quick response which is why they are assigned priority levels near the top. On the other end, lower priority IRQs are used for interrupts that don’t require immediate service like network interfaces.

Changing Interrupt Priorities

The default interrupt priority levels can be changed by programming the interrupt controller registers. This allows flexibility in assigning interrupt priorities according to the needs of the system.

For example, in a real-time control system, the analog-to-digital converter (ADC) interrupts may need higher priority than the serial port interrupts. Or in a network router, the network interface interrupts might need priority over the timer interrupt.

To change priorities, the interrupt controller peripheral has priority level registers. Setting a lower value gives an interrupt higher priority. The processor checks these priority levels to pick the active interrupt with the highest priority.

As an example, the ARM Generic Interrupt Controller (GIC) has PRIORITYRn registers where n is the interrupt number. Writing a smaller value like 0xFF to PRIORITYR10 will assign IRQ10 higher priority than the default 0x80.

Nested Interrupts

ARM processors also support nesting of interrupts. This allows high priority interrupts to preempt lower priority interrupts. For example, if IRQ10 is already being handled, and IRQ20 occurs with higher priority, then IRQ20 can become active and its interrupt service routine will run.

When IRQ20 finishes, IRQ10 can resume execution. This nested execution helps ensure critical interrupts get serviced immediately without waiting for lower priority interrupts to finish.

The interrupt controller automatically manages the stacking, prioritization and returning from nested interrupts. The processor simply executes the highest priority interrupt service routine presented to it.

Priority Level Groups

To allow flexibility in assigning priority levels, the GIC supports splitting interrupts into priority groups. For example, groups could be:

  • Group 0: IRQs 0-31
  • Group 1: IRQs 32-63
  • Group 2: IRQs 64+

Each group has its own priority levels. So IRQ50 in group 1 could have higher priority than IRQ10 in group 0, even though 50 > 10. This enables logical grouping of interrupts for priority management.

Managing Interrupt Latency

A key aspect of assigning interrupt priorities is managing interrupt latency. Latency is the delay between an interrupt being asserted and its execution. High priority interrupts have lower latency because they get serviced faster.

Latency depends on:

  • Interrupt priority grouping
  • Priority levels assigned
  • Code execution time of interrupt service routines

To guarantee low latency for critical interrupts, they need to be in the highest priority group. Their service routines must also be streamlined with minimal instructions. Checking and tuning interrupt priorities is a key step in achieving desired real-time performance.

Use Cases

Some example use cases for managing interrupt priorities in ARM systems are:

  • Real-time control – Higher priority for ADC/DAC interrupts to sample data and update outputs with determinism.
  • Sensor fusion – Lower priority for slower sensors, higher priority for critical sensors requiring fast response.
  • Network switch – Highest priority for network interface and packet processing interrupts.
  • User interfaces – Higher priority for display refresh and touchscreen interrupts for smooth UI.
  • Automotive – Highest priority for engine/brake control systems with safety critical requirements.

Optimally configuring interrupt priorities is key to building responsive real-time embedded and IoT applications using ARM processors.

Conclusion

IRQ 0 has the highest default priority in ARM processors. But interrupt priorities are flexible and can be changed by programming the interrupt controller registers. Grouping interrupts into priority levels, assigning higher priority to time-critical interrupts, and reducing service routine latency allows meeting real-time performance requirements. Tuning interrupt priorities and latency is an important consideration when building ARM-based embedded systems.

Newsletter Form (#3)

More ARM insights right in your inbox

 


Share This Article
Facebook Twitter Email Copy Link Print
Previous Article What is the Voltage of ARM Cortex M0?
Next Article How to implement atomic operations on multi-core Cortex-M0/M0+?
Leave a comment Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

2k Followers Like
3k Followers Follow
10.1k Followers Pin
- Sponsored-
Ad image

You Might Also Like

What does LR mean in assembly?

LR stands for "Link Register" and is a special register…

7 Min Read

armv7 unaligned access

Unaligned access refers to memory access where the data being…

8 Min Read
Arm

What companies use ARM chips?

ARM chips are used in a wide range of devices…

16 Min Read

Using the Cortex M0+ in USB Memory Sticks for Audio Decoding

The Cortex M0+ microcontroller from ARM is well-suited for audio…

6 Min Read
SoCSoC
  • Looking for Something?
  • Privacy Policy
  • About Us
  • Sitemap
  • Contact Us
Welcome Back!

Sign in to your account