I often see something like this void UART2_IRQHandler(void) __irq
, and I wonder why __irq is used when declaring interrupt handler, is it required or handler can work without it?
Electronic – Interrupt question ARM
armcinterruptsmicrocontroller
Related Topic
- Simple Interrupt Handling program
- Electronic – Systick in interrupt using FreeRTOS
- Electronic – STM32: UART Interrupt is triggering without any flags getting set
- Electrical – Interrupt vector address in Program Counter
- Electronic – ARM Cortex-M3 Interrupts and Interrupt service routine &interrupt handler
Best Answer
Basically, an interrupt service routine written in C is simply a function that takes no arguments and doesn't return anything
void someKindOfIsr(void)
.__irq
is a C language extension for your compiler that is used to generate special entry and/or exit assembly instructions for handling interrupts. For instance, the return instruction may be different if you are returning from an interrupt rather than a simple function to clear some type of interrupt status register.Whether it is necessary or not depends on what ARM architecture you are working with. A quick way to find out if it is necessary for your platform is to examine the assembly produced both with and without the
__irq
keyword.Even if the listing file is exactly the same both with and without the
__irq
keyword, you may want to consider leaving the__irq
keyword in place for clarity and for portability to some future platform.