Call a function at variable frequency w/o reseting a timer

Hello there :D,

I want to call a function. And each time I run this function, I need to re-run this function after x µs. x is not constant.

Thus, I configured timer1 so that its period is 1µs and used the compare match interruption.

What works well is Reset timer1 (TCNT1=0) and Set the compareA register to x (OCRA1=x) from the compareA interruption.

But I do not want to reset the timer1 since I need it for another algoritm.

What I tried is Set the compareA register to timer1+x (OCRA1=TCNT1+x).

But it doesn’t work.

Why ?

The OCRA1 is not set properly. I cannot find any explanation.

Thank you very much.

Guillaume