Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By a6000
#65854 Fairly new to ESP8266 so I try to experiment one piece at a time. When playing with timer0 interrupt, I am seeing this weird problem. If delay() is used in loop(), then RESET will occur, even if you just do delay(10). However if you change delay to delayMicroseconds() then no RESET. Did I overlook something here? Please help.

Here is the sample sketch -


#define _delta 500*80 // 500us

void inline isr(void)
{
timer0_write(ESP.getCycleCount() + _delta);
}

void setup()
{
noInterrupts();
timer0_isr_init();
timer0_attachInterrupt(isr);
timer0_write(ESP.getCycleCount() + _delta);
interrupts();
}


void loop()
{
// delay(10); // will cause RESET if commented out
delayMicroseconds(10000); // will NOT RESET if commented out
}
User avatar
By pipi61
#66059 Hi!
check c:\.....\hardware\esp8266com\esp8266\cores\esp8266\core_esp8266_wiring.c
delay() use os_timer* and other functions
likely delay and ESP.getCycleCount call common internal os function, and this os function not reentrant
delayMicroseconds() use only os_delay_us() function