Why does digitalWrite HIGH vs digitalWrite LOW take different amounts of time?


i got oscilloscope , fun, thought i'd put quick sketch toggle output fast loop run on uno.

code: [select]

#define jpin  8

void setup() {
  pinmode(jpin, output);
}

void loop() {
  static int = 0;
 
  if(i++ & 1)
    digitalwrite(jpin, low);
  else
    digitalwrite(jpin, high);
}


i found high time longer low time. thought maybe processing of "if" conditional might make difference swapped high/low , still high signal 3 times longer low signal averaging 11.5us high , 3.7us low above code regardless.

is there that's inherently more difficult / time consuming raise vs lower signal? 3x timing difference pretty significant. haven't looked low level programming on uno see how control registers modified there seems wrong.

oscilloscopes r fun! :) 

try:

void loop()
{

digitalwrite( jpin, !digitalread(jpin) );

}


Arduino Forum > Using Arduino > Programming Questions > Why does digitalWrite HIGH vs digitalWrite LOW take different amounts of time?


arduino

Comments

Popular posts from this blog

Error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode - Raspberry Pi Forums

class MPU6050 has no member named begin

missing filename after '-o'