Página 1 de 1

interrupções no esp 8266

MensagemEnviado: 24 Mai 2019 17:26
por wilson souza
tenho um módulo sonoff aqui que resolvi reprogramá-lo com a ide do arduino.
montei um web server e funcionou.
testei o wifimanager, e funcionou.

resolvi testar a interrupção do esp 8266 e gravei isto no módulo.



}
Código: Selecionar todos
const byte interruptPin = 0;
volatile byte interruptCounter = 0;
int numberOfInterrupts = 0;
 
void setup() {
 
  Serial.begin(115200);
  pinMode(interruptPin, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(interruptPin), handleInterrupt, FALLING);
 
}
 
void handleInterrupt() {
  interruptCounter++;
}
 
void loop() {
 
  if(interruptCounter>0){
 
      interruptCounter--;
      numberOfInterrupts++;
 
      Serial.print("An interrupt has occurred. Total: ");
      Serial.println(numberOfInterrupts);
  }
 
}


e não funciona.

recebo isto da serial do arduino ide

Código: Selecionar todos

SDK:2.2.1(cfd48f3)/Core:2.5.2=20502000/lwIP:STABLE-2_1_2_RELEASE/glue:1.1-7-g82abda3/BearSSL:a143020
ISR not in IRAM!

Abort called

>>>stack>>>

ctx: cont
sp: 3ffffdb0 end: 3fffffc0 offset: 01b0
3fffff60:  3fffdad0 00000001 3ffee28c 40201318 
3fffff70:  00000000 00000000 ffefeffe 3ffee2e4 
3fffff80:  3fffdad0 00000000 3ffee2b4 401003da 
3fffff90:  feefeffe 00000000 3ffee2b4 40201069 
3fffffa0:  feefeffe feefeffe feefeffe 40201c34 
3fffffb0:  feefeffe feefeffe 3ffe8504 401006c5 
<<<stack<<<

 ets Jan  8 2013,rst cause:1, boot mode:(3,6)

load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v8b899c12
~ld

SDK:2.2.1(cfd48f3)/Core:2.5.2=20502000/lwIP:STABLE-2_1_2_RELEASE/glue:1.1-7-g82abda3/BearSSL:a143020
ISR not in IRAM!



o que esta dando errado?

Re: interrupções no esp 8266

MensagemEnviado: 24 Mai 2019 18:01
por tcpipchip
Muito estranho isto, eu desenvolvi vários projetos com a Sonoff e com interrupts (para detectar botao pressionado, infrared) e nunca tive problemas!

Código: Selecionar todos
//Button interrupt
void ICACHE_RAM_ATTR Button_Interrupt()
{
    Button_Press = HIGH;
}

attachInterrupt(TRIGGER_PIN, Button_Interrupt, RISING);
}


Funciona perfeitamente!

Re: interrupções no esp 8266

MensagemEnviado: 25 Mai 2019 10:10
por andre_luis
É provável que os multiplos glitches do contato da chave estejam causando reentrancia da interrupçao.
Experimenta desabilitar a interrupção logo que entrar na função de tratamento dela handleInterrupt(), ou apenas implementar um debouncing.