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?
// 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;
}
}
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
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.