- Can interrupts occur if I enable interrupts & then
quickly disable them ?
No. Specifically, when working in assembly you need a small delay between EI & DI. If
you insert a NOP command between EI & DI then this allows the interrupt enable command
to complete before DI takes effect. Thus allowing all pending interrupts to be serviced
before interrupts are disabled. Any pending interrupts will be serviced in the order of
their priority and they all will be serviced at once before control is returned to
non-interrupt code.
The reason this delay is needed is because the assembly command EI doesn't take effect
immediately but DI does. EI takes effect following the instruction that follows it.