Pages: [1]   Go Down
Author Topic: duration of signal  (Read 307 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi!

All else being standard, how long will the output being set in this case:
Code:
 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
Logged

Montréal, Qc
Offline Offline
Full Member
***
Karma: 0
Posts: 185
Practice safe hex!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

"Pilots believe in a clean living... they never drink wisky from a dirty glass."

Pages: [1]   Go Up
Jump to: