Skip to content

Race in interrupts?? #2916

Closed
Closed
@andbjo

Description

@andbjo

Basic Infos

Hardware

Hardware: ESP-12E
Core Version: ?2.1.0-rc2?

Description

Problem description
In file: esp8266/cores/esp8266/core_esp8266_wiring_digital.c
In function: __attachInterrupt
the interrupt handler is set before cleaning interrupts for the receive pin witch make the receive sensitive to transitions high to low or low to high.
When this happends the device gets stuck in boot phase.

My proposal is to move
the line interrupt_handler_t *handler = &interrupt_handlers[pin]; to after cleaning interrupt.
As:

extern void ICACHE_RAM_ATTR __attachInterrupt(uint8_t pin, voidFuncPtr userFunc, int mode) {
if(pin < 16) {
// interrupt_handler_t *handler = &interrupt_handlers[pin];
handler->mode = mode;
handler->fn = userFunc;
interrupt_reg |= (1 << pin);
GPC(pin) &= ~(0xF << GPCI);//INT mode disabled
GPIEC = (1 << pin); //Clear Interrupt for this pin
// Put tis line here:
interrupt_handler_t *handler = &interrupt_handlers[pin];
GPC(pin) |= ((mode & 0xF) << GPCI);//INT mode "mode"
}
}

Settings in IDE

Module: NodeMCU
Flash Size: 4MB
CPU Frequency: 80Mhz
Flash Mode: ?qio?
Flash Frequency: 40Mhz
Upload Using: SERIAL/USB
Reset Method: nodemcu

/Anders

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions