Interrupt and accurate timing issues

Ok, so I have an application that pulls an input pin low. The sketch has to wait a specified time and then turn an ouput high.

Firstly, the whole cycle takes <512us. The interrupt input pin and one of the outputs are connected together, so I have to switch the output back to an input at the end of it all so there isn’t a short when the interrupt is next pulled low.

Now, I did try. I setup an interrupt on a pin that called my timing routine.
The timing routine changed the output pin to low, then changed it from being an input to an output.
There is a fixed delay of 255 us then a variable delay of 0-255 us based on the value of a internal variable.
Then the output is turned high. The rest of the second 255us is waited out and the output is turned into an input and we are done.

However it didn’t seem to work at all.
Am I expecting too much speed wise from a normal arduino sketch? Is the delay routine not accurate enough?

Am I going to have to switch to inline assembly to get this to work?

Too much guesswork in framing an answer, as the problem may be general or a tiny error. You should post your code, in code tags.

Speed shouldn’t be an issue with such timing.

I just re-wrote the app from scratch with a scope attached, it LOOKS like the timings are all as expected.

I will hook it back up to the target hardware and test again.

So yeah, speed shouldn't be an issue here. I must have made a coding mistake. If it doesn't work I will post the new code, otherwise assume it's all working :slight_smile:

Pyrofer:
I just re-wrote the app from scratch with a scope attached, it LOOKS like the timings are all as expected.

Hmmm. Maybe I should try writing with a scope attached. :slight_smile: Hey, whatever works!