Skip to content

Latest commit

 

History

History
57 lines (37 loc) · 1.23 KB

NOTES.md

File metadata and controls

57 lines (37 loc) · 1.23 KB

Notes

Notes down the observations, experiences and occurrences during the development of the repo.

Useful for explaining certain decisions.

speed of digitalWriteFast:

On Arduino Uno clone, 16MHz

digitalWriteFast is so fast that

void loop() {
  digitalWriteFast(pinNum, HIGH);
  digitalWriteFast(pinNum, LOW);
}

The above did not result in 50% duty cycle. Graph 1

Rather, the pin stays low for quite some time until the program loops again.

Took around 600ns for the program to repeat

So, the below was done instead:

void loop() {
  digitalWriteFast(pinNum, HIGH);
  digitalWriteFast(pinNum, LOW);
  digitalWriteFast(pinNum, HIGH);
  digitalWriteFast(pinNum, LOW);
//	...  and it goes on, multiple times
  digitalWriteFast(pinNum, HIGH);
  digitalWriteFast(pinNum, LOW);
  digitalWriteFast(pinNum, HIGH);
  digitalWriteFast(pinNum, LOW);
}

It only took 250ns to toggle, meaning it took only 250ns/2= 125ns to set or clear the pin/port. Graph 2

speed of digitalWrite:

On Arduino Uno clone, 16MHz

It took 12.56us to toggle, meaning it took 12.56us/2= 6280ns to set or clear the pin/port.

50 times slower than direct port manipulation!

Graph 3