arduino uno timers

i am working on a project where i have calculate time which will be triggered by interupts for example ist time an interuptt occurance will start the time and the next timer on interuptts i want to stop timer.and i wanted to take guidance on how to use timers but specially how to start and stop timers in arduino uno using arduino ide.

You have an interrupt service routine that is being triggered by something (say an external interrupt).
You want to measure the time between one call of the interrupt service routine and the next.
Is that it ?

One method it so set a (volatile) global variable with the current value of millis() in the ISR and on the next invocation, check the difference between the new current value of millis() and the old stored value.

Record micros() on first event.
Record micros() on second event.

Duration = secondEvent - firstEvent.

No timer needed or useful.

thank you for guidance but i needed more accurate than just in usec what if i want calculate time less tha a 1 usec.

What level of accuracy do you want? An Arduino with a 16MHz clock takes 62.5 nano seconds per instruction. There are no many of those in a micro second.

how can i get the time in nano seconds as the mllis() can only return upto 1usec.

I've not done it my self, but see here to benefit from the experience of others: Google

how can i get the time in nano seconds

You can not.

mllis() can only return upto 1usec


millis() returns milli-seconds (as the name suggests) or 1/1000 of a second.
micros() returns micro-seconds or 1/1000000 of a second.

A single nop instruction takes 62.5 nano seconds, as already noted.

thank you for the guidance and i hope this will address my problem.