Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By nimaaryamehr
#69228
DTrain123 wrote:Do you need to disable interrupts when your inside an interrupt handler?
I thought you could only have one interrupt happening at a time?



If I want to get pin0 for another interruption
How should I do this?
User avatar
By QuickFix
#69239
DTrain123 wrote:Do you need to disable interrupts when your inside an interrupt handler?
I thought you could only have one interrupt happening at a time?

It actually depends on what the interrupt needs to be doing.
When there are shared variables (for instance), you might not want to read/write their value at some points, since it may mess up your program flow.

You can have multiple interrupts at one time (each connected at a different GPIO), so you have to carefully consider whether you want to disable/re-enable interrupts inside an interrupt (but it's not compulsory).
User avatar
By DTrain123
#69307
QuickFix wrote: you have to carefully consider whether you want to disable/re-enable interrupts inside an interrupt (but it's not compulsory).


I had a look at core_esp8266_wiring_digital.c where attachInterrupt is defined.
On line 127 it has the code which calls the interrupt handler method:
Code: Select all      // to make ISR compatible to Arduino AVR model where interrupts are disabled
      // we disable them before we call the client ISR
      uint32_t savedPS = xt_rsil(15); // stop other interrupts
      handler->fn();
      xt_wsr_ps(savedPS);

In Arduino.h noInterrupts() is defined:
Code: Select all#define noInterrupts() xt_rsil(15)

So interrupts have already been disabled before your method gets called. So no need to call noInterrupts() in your interrupt handler code.