Arduino Due and attachInterrupt

Hi,

I have a big problem only with my attachInterrupt on arduino Due.
When i add this line :

 attachInterrupt(6, message, FALLING );

The message function is directly called even if I use other operating mode like LOW, RISING, etc

I tried my code on Arduino MKR1000 and i don't have this problem.

I give you the code below :

int val = 0;
  
void setup()
{
  Serial.begin(115200);
  delay(2000);
      Serial.println(digitalRead(6));
  pinMode(6, INPUT_PULLUP);
 attachInterrupt(6, message(), FALLING ); 
     Serial.println(digitalRead(6));
}
  
void loop()
{
    Serial.print("LOOP:");
    Serial.println(val);
    delay(100);
    val++;
}
  
void message()
{
    Serial.print("INT:");
    Serial.println(val);
}

Do you have any solution ?

It might be due to EMI on pin 6 seen as a falling edge. Do you have a pull down or pull up resistor on this pin ?

Don't use the weak internal pullups, use external pullup résistors like 1KOhms or more.

My experiment also reveals that the MCU is interrupted once during the execution of this instruction: attachInterrupt(digitalPinToInterrupt(6), message, FALLING);.

One may proceed to program the interrupt using ASF Strategy in order to make an authentic declaration that the above-mentioned instruction is really not compatible with DUE though it works fine with UNO.

Help is being sought to get the link for ZIP version of the asf.h file.

i tried on different pin but there are the same problem on each pin.
and using external pullups don't solve the problem.

In fact it's a software problem.

This snippet works as expected (I hook a pull_up resistor on pin 6 = PC24). I tested it with a button switch without a debounce( there should be a debounce either software or hardware):

// Hook a pull-up resistor of 1K or more between pin 6 and 3.3V

volatile boolean Flag;      

void setup()
{
  Serial.begin(250000);
  pinMode(6, INPUT);
  PIOC->PIO_ISR;                    // Clear status register
  NVIC_ClearPendingIRQ(PIOC_IRQn);  // Clear pending ISR
  attachInterrupt(6, message, LOW);
}

void loop()
{

  if ((Flag == true)){
    Serial.println(" pin 6 is low ");
    Flag = false;
  }
}

void message()
{ 
  Flag = true; 
}

Unfortunately, the setup of Post#5 is not working in my case!