Go Down

Topic: attachInterrupt (Read 920 times) previous topic - next topic

mantoui

I have a 2.8v pulse (1us width) every second on pin 7 (I can see it on scope) and Maple and Uno version work, but
I get no hits in the interrupt handler on the DUE with the following sketch.  What am I missing?

Code: [Select]

// gpspps

volatile unsigned long us;
volatile int tick=0;

void handler() {
us = micros();
tick=1;
}

void setup() {
Serial.begin(9600);
attachInterrupt(7,handler,RISING);
}

void loop() {
    static unsigned long prev = 0;
    unsigned long t;
    char str[32];
if (tick)  {
            t= us-prev;
            sprintf(str,"%ld us  %ld ppm",t,t-1000000);
Serial.println(str);
tick=0;
            prev=us;
}
}

mantoui

Never mind, problem was with IDE 1.5, works with IDE 1.5.1 (though it didn't like my hardware/ folder).
So sketch is working now, and I can use EM-406A GPS pps to measure frequency of DUE clock/crystal and get measurements consistent with using an NTP host as frequency reference. The Sparkfun EM-406A operates at 5v, but specs and scope show TX and pps are at 2.8v so no level conversion needed.  Frequency results and various sketches at
  https://github.com/manitou48/crystals

Arctic_Eddie

Pin 7 is not an interrupt pin. The first item in the attachInterrupt() call is an interrupt number and not a pin number. See the linked image for details. You may also need to set the interrupt pin as an input.

http://arduino.cc/forum/index.php?topic=128464.0

Arctic_Eddie

Oops, I see that the Due has different options for the first argument and any pin can be an interrupt.


Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy