# Difference between FIQ and IRQ

Im working on TI based processors now and they have 2 types of Interrupt configuration(FIQ or IRQ).I have seen such interrupts before when i was doing a hobby project using a LPC1778 but since i didnt use interrupts i didnt mind them. I need to use them now for a project and its essential that i find out the difference so that i can use them appropriately. Both are interrupts but what makes them different such that they are identified with two seperate names?

Any help would be great.

Thanks.

• FIQ (Fast Interrupt reQuest) is basically a higher priority interrupt (which will interrupt even the interrupt handler of a normal IRQ). See this excellent anser on stack overflow – jms Mar 24 '16 at 8:02
• The top answer in the SO link you shared suggests that an FIQ is a higher priority interrupt than IRQ and if a FIQ occurs,other interrupts get disabled. Do those IRQ's get reenabled after the FIQ is serviced? – AkshayImmanuelD Mar 24 '16 at 9:06
• And also another answer states that FIQ cannot be written in C – AkshayImmanuelD Mar 24 '16 at 9:15
• When a FIQ is active, the IRQ handler is disabled. The IRQ hardware itself isn't disabled. Any pending IRQ interrupts will be handled as soon as the FIQ finishes, and normal code execution wil resume as soon as all interrupts have been handled. – jms Mar 24 '16 at 9:35
• Ok so FIQ gets serviced->IRQ gets serviced->Normal code. But what about FIQ being wriiten only in c? – AkshayImmanuelD Mar 24 '16 at 9:41

The FIQ is a second instance of the interrupt logic. The key differences are:

1. low-latency, low-jitter entry

The entry for the FIQ is at the end of the vector table, so it isn't limited to a single instruction, which allows you to begin the interrupt handler directly at this point.

In addition, the time between the assertion of the FIQ and the execution of the first instruction in the FIQ handler is guaranteed to be fixed, so it is possible to implement exactly timed processing here. If the current instruction needs multiple cycles to complete (e.g. an ldm instruction), it is aborted and restarted after the handler completed.

In addition, the FIQ mode has shadow registers for r8 to r14, while the other special modes (IRQ, SVC, ABT, UND) only have r13 and r14 shadowed, so it is possible to keep local state between runs in registers, which again speeds up handler startup.

2. separate enable/disable logic

The FIQ can remain enabled while IRQs are executing (the FIQ logic disables interrupts, so the FIQ is higher priority), which is again a nod towards realtime applications.

The Cortex-M implements priority handling inside the interrupt controller, guarantees constant time entering any interrupt and does away with the shadow registers as entering the interrupt handler requires multiple memory accesses anyway.

This means the interrupt latency is significantly higher on Cortex-M, but still low-jitter. For high-frequency interrupts, this is a significant disadvantage.

For example, implementing a software serial port in an FIQ handler is easy:

fiq_setup:
MOV r0, #MODE_FIQ
MOV cpsr, r0          // switch mode to FIQ
MOV r8, #GPIO_BASE    // address of GPIO controller
MOV r9, #2            // Tx line high
MOV r0, #MODE_SVC
MOV cpsr, r0          // switch back to SVC mode


This prepares registers r8 and r9 for when the FIQ handler runs

fiq_handler:
str r9, [r8]
ldr r9, [r8]
// handle the bit read from the Rx line
// prepare the next bit for Tx
subs r15, r14, #-4


If the routine is short enough, you can set up a timer with several hundred KHz that triggers an FIQ, and still use a single-digit percentage of CPU time only.

LPC17xx is Cortex M, which has its own interrupt handling via NVIC that is different from other (bigger) ARM processors. There is no FIQ in Cortex M, and interrupt/fault handling is different because there are no banked registers except SP.

• This answer to me seems to very skilfully avoid answering the question of "What's the difference" and in stead attempt at answering "Why didn't I use them in the LPC" – Asmyldof Mar 24 '16 at 8:44
• Full answer requires careful stufy of the documentation specific to your hardware - which I assumed to be LPC17xx lacking any other information. – Turbo J Mar 24 '16 at 9:30
• You mean the OP's information? Where he says in LPC he never cared about interrupts and now is working with a TI? And where he says that TI has FIQ and IRQ and now wonders what the difference is? That information? You, the question the title makes up. – Asmyldof Mar 24 '16 at 18:13