-->
Page 1 of 1

ESP8226 pin toggling takes some time

PostPosted: Thu Oct 06, 2016 3:50 am
by rosenrot
Dear all,

I just saw that toggling the GPIO0 takes around 3.28us. Could someone tell me why? The CPU frequency is 80MHz right? This would give a clock cycle of 12.5ns.

I tried this on an ESP-14 with the BasicOTA.ino running in background but that should not bother it too much.

Code: Select allpinMode(0, OUTPUT);
digitalWrite(0, HIGH);
digitalWrite(0, LOW);
digitalWrite(0, HIGH);
digitalWrite(0, LOW);
digitalWrite(0, HIGH);
digitalWrite(0, LOW);


Image

UPDATE: Ok, for some reason with the same code now I get 420ns for a pin toggle. This is still far to slow. Wifi and OTA is turned off, basically I use an empty sketch now.

Please someone help me.

Re: ESP8226 pin toggling takes some time

PostPosted: Thu Oct 06, 2016 12:19 pm
by rosenrot
Maybe I got something completely wrong but I do not get why the ESP8266 is so slow with pin actions.

Why is there such a long delay after switching the pin to INPUT?
Why is there also a long delay after switchting the pin to OUTPUT again?

What do I miss???

Code: Select allpinMode(0, OUTPUT);
digitalWrite(0, LOW);
digitalWrite(0, HIGH);
digitalWrite(0, LOW);
digitalWrite(0, HIGH);
digitalWrite(0, LOW);
digitalWrite(0, HIGH);
digitalWrite(0, LOW);
digitalWrite(0, HIGH);
digitalWrite(0, LOW);
pinMode(0, INPUT_PULLUP);
pinMode(0, OUTPUT);
digitalWrite(0, HIGH);
digitalWrite(0, LOW);
digitalWrite(0, HIGH);
digitalWrite(0, LOW);
digitalWrite(0, HIGH);
digitalWrite(0, LOW);
digitalWrite(0, HIGH);
digitalWrite(0, LOW);
digitalWrite(0, HIGH);

Image

Re: ESP8226 pin toggling takes some time

PostPosted: Thu Oct 06, 2016 11:47 pm
by Pablo2048
Everyone with Arduino have nearly complete source code so look into core_esp8266_wiring_digital.c and You will see...
Short story: If You want fast GPIO change (not using GPIO16), use GPOS/GPOC instead of digitalWrite()...