Whats the difference between NMI and IRQ?
The main differences are as follows: NMI has higher PRI than IRQ, and no matter how the interrupt flag(I) indicates in the state register (P), CPU will receive NMI without exception; however, CPU will not receive IRQ unless the corresponding flag in the state register is cleared. NMI can only be set as edge-triggered; however, IRQ can be set as both edge-triggered and level-triggered. Only one interrupt can be set as NMI at a time; however, two or more interrupts can be set as IRQ-level simultaneously.