-->
Page 1 of 1

Avoid "loop ()" function to improve CPU Speed

PostPosted: Tue Jun 13, 2017 4:38 pm
by nazimba
Hi there! Is there any way to avoid looping function in the ESP8266 integrated?
I mean to do it in the same way that it is possible to achieve it in most of Atmel MCU, taking advantage of the speed processor.
This would be the example code and here is a link to a post on this topic on the AVR Freaks site.
http://www.avrfreaks.net/forum/attiny85 ... stead-4mhz
I hope something like this is possible.
Thanks in advance.

Code: Select allvoid setup() {
 
   pinMode(LED_BUILTIN, OUTPUT);

      while(true) { 
         digitalWrite(LED_BUILTIN, HIGH);
         digitalWrite(LED_BUILTIN, LOW);
      }
}


ERROR MESSAGE:
Archiving built core (caching) in: C:\Users\Nazim\AppData\Local\Temp\arduino_cache_248748\core\core_esp8266_esp8266_nodemcuv[code]2_CpuFrequency_80,UploadSpeed_115200,FlashSize_4M3M_08186d0190bdc8e1d53eb1574336cbab.a
C:\Users\Nazim\AppData\Local\Temp\arduino_build_799418/arduino.ar(core_esp8266_main.cpp.o):(.text._ZL12loop_wrapperv+0x4): undefined reference to `loop'

C:\Users\Nazim\AppData\Local\Temp\arduino_build_799418/arduino.ar(core_esp8266_main.cpp.o): In function `loop_wrapper':

C:\Users\Nazim\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/core_esp8266_main.cpp:110: undefined reference to `loop'

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

Re: Avoid "loop ()" function to improve CPU Speed

PostPosted: Wed Jun 14, 2017 10:19 am
by martinayotte
Simply use an empty loop() :
Code: Select allvoid loop() {}

Re: Avoid "loop ()" function to improve CPU Speed

PostPosted: Wed Jun 14, 2017 2:13 pm
by nazimba
martinayotte wrote:Simply use an empty loop() :
Code: Select allvoid loop() {}



Have you seen my post at AVR Freaks?

Re: Avoid "loop ()" function to improve CPU Speed

PostPosted: Thu Jun 15, 2017 1:09 pm
by martinayotte
Yes ! ... but I must admit that I didn't took time to read the whole thing.
I've understood that you wish to have the tightest loop to get high speed GPIO toggling.
But what else I've missed ?
The fact that you still have an empty loop() to satisfy the linker doesn't prevent you to do the while() in setup().

EDIT : (almost forgot) But beware that WiFi won't be able to run if you stuck in a while() and you will need to disable the watchdog.