-->
Page 1 of 2

Festest way to turn pin on

PostPosted: Mon Jan 04, 2016 3:06 pm
by Falesh
On the Arduino I use commands like "PORTD |= _BV(7)" & "PORTD &= ~_BV(7)" to turn pins on and off really quickly. I tried to use this on the NodeMCU ESP8266 but it didn't work. Is there an alternative that can be use with the ESP8266 which is just as fast?

Re: Festest way to turn pin on

PostPosted: Mon Jan 04, 2016 3:55 pm
by martinayotte
You can take a look at the file cores/esp8266/core_esp8266_wiring_digital.c how the digitalWrite() is doing it job, but I don't think you can end up with any thing faster, digitalWrite() is already well optimized.

Re: Festest way to turn pin on

PostPosted: Mon Jan 04, 2016 4:39 pm
by Falesh
That's good to know, digitalWrite() for the Arduino is very slow compared to the PORTD |= _BV(7) method.

Re: Festest way to turn pin on

PostPosted: Mon Jan 04, 2016 5:01 pm
by martinayotte
Yes, I know !
But ESP has another advantage : it is about 10 times faster than ATmega328. ;)