Function Timing Diagram

hi, does any one know from where i can get the timing diagram of the functions of Arduino [1280 16MHz]?? i.e. in how many clock cycles the functions are done cos i need to time my 'void loop()'...

thanks :) GSerri

functions like:

DigitalWrite() DigitalRead()


thanks :D

How precise do you need the timing to be and for what purpose?

If your loop is simply to slow for time critical things, get rid of digtalRead() and digitalWrite(). Those are horribly inefficient. Access the correct bits in the ports directly or use the digitalReadFast and digitalWriteFast functions. For information purposes, often it’s just enough to have a counter be incremented in each invocation of loop and print out the difference of microSeconds() every 100000 or 1000000 iterations. To get more precise measurements, you can also program a timer a measure the number of clock cycles between each occurrence (and subtract the timer overhead).

If you need it for an emulator, have it generate a clock cycle count from the assembly listening. The execution times for all instructions are listed in the Atmel data sheet. This is also the best way if you’re dealing with events below µs resolution and you need to check if you can keep up.


The best way is to buy a logic analyser (they are really cheap these days) and measure it.

Or for a reasonable approximation call the function 100,000 times, record the time with micros() before and after and / the difference by 100,000.


Or use your oscilloscope as a poor man's logic analyser. Toggle a free digital output every time you enter a function (this can be done with one assembly instruction in 2 clock cycles) and attach your probe to that pin.


thanks guys managed to find the time:D