AdderD:
I wouldn't even use a timer. On the Due you can interrupt on any digital pin changing state. So, set a pin change interrupt on the pin in question. Now you're half way there. The other part of the equation is how to detect how long the pulse was. Well, micros() gives you the number of microseconds elapsed since system start up. So you capture the current micros() value each time the pin state changes. You compare the new state to the old state and compare the current value with the old one and you end up with a determination of what happened. The pin change interrupt is just that so you don't need to spend a single moment polling for anything - it truly would be a background task.So, look at the reference for attachInterrupt: https://cdn.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/
I initially tried using attachInterrupt.....but it seemed to confuse the Due and it would act erratically.
Due to the short pulses (64uS) maybe?
I would have it jump to a function, and first line in the interrupt function would be detatchInterrupt (to stop it from restarting the interrupt function after that initial state change in the input wire)....but sometimes it would still do a couple loops of the interrupt function? It was almost like it wasnt detatching the interrupt quickly enough....? Is that even possible?