-->
Page 1 of 1

User ISR + delay() = RESET?

PostPosted: Fri May 12, 2017 1:28 am
by a6000
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
}

Re: User ISR + delay() = RESET?

PostPosted: Thu May 18, 2017 5:30 pm
by pipi61
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