Re: NodeMCU and Interrupt
Posted: Thu Mar 15, 2018 3:21 am
what you are seeing and treating is only the symptom. the cause is that your button is not debounced, thus your interrupt routine is called several times during first 5-10ms of keypress. During this time the isr (or other part) is still in serial.println() which itself is using interrupts, asking for trouble on systems with limited interrupt / stack capabilities like esp8266 (It is not like avr µC where you could disable or prioritize interrupts for ease of game).
a) in isr: only set flags, never use delay()
b) isr belongs to ICACHE_RAM
void ICACHE_RAM_ATTR isr(void)
c) keys need debounce
a) in isr: only set flags, never use delay()
b) isr belongs to ICACHE_RAM
void ICACHE_RAM_ATTR isr(void)
c) keys need debounce