Graynomad:
Yes I see.//THIS interrupt should be disabled inside the ISR, to prevent multiple calls to the ISR. You should not use millis() & micros() from an ISR
...
ISR (INT0_vect) {
mi = micros();
PORTB != (1 << PB5);
microshigh2 = micros();
deltamicros = microshigh2-microshigh1;
PORTB &= ~(1 << PB5);
// never call an large function from an ISR, set a flag and call it from loop()
do_calc = true;
}
void setup() {
...
}
void loop() {
if (do_calc) {
zzpcalc();
do_calc = false;
}
external();
}
You are using micros() which IIRC in turn needs timer0 to be running and that will cause some jitter for the reasons we stated above. It may also be worth disabling the timer0 interrupt and getting your micros information directly from the timer hardware. But I haven't delved deeply into your logic so understand what's needed. NOTE: Why is deltamicros a float, expecting fractional values? ______ Rob