Go Down

Topic: attachInterrupt() makes due halt? (Read 140 times) previous topic - next topic


Hi I've got my first DUE (before, I had UNO)

and trying "UPGRADE" my gizmo that uses ISR.

However it seems attachInterrupt() makes due board stop.

and this is my code

Code: [Select]
#include <Wire.h>

void setup()
    pinMode(12, OUTPUT);
    pinMode(13, OUTPUT);
    digitalWrite(13, HIGH);
  //pinMode(22, INPUT_PULLUP);
    attachInterrupt(22, inter, RISING);  
  Serial.println("SETUP 66");

void loop() {}

void blinking()
  digitalWrite(13, HIGH);
  digitalWrite(13, LOW);

void inter()

I put hell lot of Serial.println() in my code for Test Purpose

and I've got this in my Serial Monitor

Code: [Select]

Looks weird... I will look for your response.

Thank you in advance!


Inside an ISR, a good practice is to avoid any length such as Serial.print or delay, just set a flag or clear/set a register.

Try the example sketch in Arduino Playground for attachinterrupt(), it should work.


Many Thanks !

I'd never try code on playground directly.

How ironic that I've read that post whole day.

Haha Thank you for your kind help.

BTW that code works fine on UNO

what difference make that happening?


That's why it breaks. The millis() timer which drives delay() doesn't update properly inside an interrupt.

Turn the LED on in the interrupt and record the value of millis() at that time. The main loop can check if the LED is on and turn it off if the time is up.
"The problem is in the code you didn't post."

Go Up