When you answer, please specify which Teensy versions your answer can apply to.
How to immediately schedule an output pin to flip in X uS from now. X can be from 400 - 2800uS(microseconds).
sub 1uS resolution preferred, but 4uS resolution of micros() would be acceptable.
The general case might use delay, or constantly check elapsedMicros(), but I am interested in scheduling an interrupt to occur or use peripherals because I cannot guarantee acceptable loop times.
This project has further constraints.
The scheduling task above must be non blocking and happen quickly within the ISR of a pin change falling interrupt.
Other things that must happen within that same ISR:
Immediately set output pin High,
compute X = constrain(time since previousRising + offset[+/- 400 - 2800uS])
Offset is a frequently changing value based on data received via serial.
I would like to avoid turning off interrupts at any point if at all possible.
Each input pin has a corresponding output pin. Input Capture seems like the right way to go but Im not clear on how to use it, and ...
This same process is happening on a minimum of 4 other pins at the same time.
The better solution maximizes the number of pins I can do this on.
It is highly likely that some input pins will trigger simultaneously but have different offset values, thus different output timing.
This sketch uses PulsePosition library to read input PPM stream at the same time, so the scheduling approach must be compatible.
Edit: I forgot to mention, this one shot timer/interrupt scheduling task comes up about every 10mS on each pin and they are semi regular. Their clocks do creep.
How to immediately schedule an output pin to flip in X uS from now. X can be from 400 - 2800uS(microseconds).
sub 1uS resolution preferred, but 4uS resolution of micros() would be acceptable.
The general case might use delay, or constantly check elapsedMicros(), but I am interested in scheduling an interrupt to occur or use peripherals because I cannot guarantee acceptable loop times.
This project has further constraints.
The scheduling task above must be non blocking and happen quickly within the ISR of a pin change falling interrupt.
Other things that must happen within that same ISR:
Immediately set output pin High,
compute X = constrain(time since previousRising + offset[+/- 400 - 2800uS])
Offset is a frequently changing value based on data received via serial.
I would like to avoid turning off interrupts at any point if at all possible.
Each input pin has a corresponding output pin. Input Capture seems like the right way to go but Im not clear on how to use it, and ...
This same process is happening on a minimum of 4 other pins at the same time.
The better solution maximizes the number of pins I can do this on.
It is highly likely that some input pins will trigger simultaneously but have different offset values, thus different output timing.
This sketch uses PulsePosition library to read input PPM stream at the same time, so the scheduling approach must be compatible.
Edit: I forgot to mention, this one shot timer/interrupt scheduling task comes up about every 10mS on each pin and they are semi regular. Their clocks do creep.
Last edited: