Consider this code:
void loop() {
digitalWrite(pinTest, HIGH);
digitalWrite(pinTest, LOW);
}
On an Arduino Mega 2560, running 16MHz (=0.06us), I would expect the width of the pulse to be somewhere around 0.1us.
However, when measuring with my oscilloscope, I get around 4us high and 5-6 us low. I understand it could take some cycles to run the digitalWrite code, but this seems quite a lot.
How is that difference explained?