User ISR + delay() = RESET?
Posted: Fri May 12, 2017 1:28 am
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
}
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
}