Do interrupts interrupt other interrupts on Arduino?

后端 未结 3 1987
别跟我提以往
别跟我提以往 2021-02-06 23:51

I have an Arduino Uno (awesome little device!). It has two interrupts; let\'s call them 0 and 1. I attach a handler to interrupt 0 and a differ

3条回答
  •  长情又很酷
    2021-02-07 00:30

    The documentation mention that Arduino interrupts have priority:

    If your sketch uses multiple ISRs, only one can run at a time. Other interrupts will be executed after the current one finishes in an order that depends on the priority they have.

    It also provides a link for additional information:

    For more information on interrupts, see Nick Gammon's notes.

    According to sections What is interrupt priority? and Can interrupts occur while interrupts are disabled?, we can conclude that:

    1. Interrupts are based on the list of flags. When an event occurs the corresponding flag is set.
    2. If the ISR can't fire right now, it can be called at any time later because the flag is saved.
    3. There is a list of all available interrupts, and it generally depends on the chip. The higher up the list, the higher the priority.

    So, different interrupts will not interrupt each other. They will be executed according to their priority.

提交回复
热议问题