Go Down

Topic: duration of signal (Read 370 times) previous topic - next topic

poesel

Hi!

All else being standard, how long will the output being set in this case:
Code: [Select]

 digitalWrite(CLK, LOW);
 digitalWrite(CLK, HIGH);
 digitalWrite(CLK, LOW);


I would think it would be at least one clock cycle, so 1/16MHz = 62,5ns, but is that so?

thanks for the help

xSmurf

From http://www.arduino.cc/playground/Learning/PortManipulation:

Quote
If you look at the source code in lib/targets/arduino/wiring.c, you will see that digitalRead() and digitalWrite() are each about a dozen or so lines of code, which get compiled into quite a few machine instructions. Each machine instruction requires one clock cycle at 16MHz, which can add up in time-sensitive applications. Direct port access can do the same job in a lot fewer clock cycles.


I suggest you take a look at the article for more information on the subject. But basically you will need to use the port registers if you want to achieve 1 instruction per cycle.
"Pilots believe in a clean living... they never drink wisky from a dirty glass."

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy