Right External Interrupt Function on Teensy 4.1?

nick703

Member
Code:
#define  Input_Status          21

bool Input_Start = false;

void setup() 
{
  // put your setup code here, to run once:
  Serial.begin(19200);

  pinMode(Input_Status, INPUT_PULLUP);

  attachInterrupt(digitalPinToInterrupt(Input_Status), CheckInputIntHandler, FALLING);

}

void loop()
{
  // put your main code here, to run repeatedly:
  if(Input_Start)
  {
      Input_Start = false;
      Serial.println("Yes External Interuupt Occured!!");
  }
  delay(5);

}


void CheckInputIntHandler()
{
  NVIC_DISABLE_IRQ(Input_Status);
  Input_Start = true;
  NVIC_ENABLE_IRQ(Input_Status);
}


Please anybody clear me is that correct way to declare external interrupt?
can i disable and enable interrupt in interrupt handler?
yes is compile and running. is that ok?
 
Thanks MarkT

is that required NVIC_DISABLE_IRQ(Input_Status); ?

Not sure of any reason to do the Disable and Enable, haven't seen it done.

That is a short _ISR so it might fire twice in quick succession as the faster MCU may not process the interrupt completion in that time and call it immediately again.

Doing a forum search for 'DSB' command as ASM will find notes on that.
 
Back
Top