Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By rosenrot
#56140 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.
Last edited by rosenrot on Thu Oct 06, 2016 2:20 pm, edited 1 time in total.
User avatar
By rosenrot
#56153 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
User avatar
By Pablo2048
#56174 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()...