当时的重启代码复制如下:
Code: Select all
abort() was called at PC 0x40378837 on core 1
Backtrace: 0x40377776:0x3fc92ac0 0x4037a591:0x3fc92ae0 0x4037fb45:0x3fc92b00 0x40378837:0x3fc92b80 0x40378949:0x3fc92bb0 0x42003741:0x3fc92bd0 0x42001987:0x3fc92c10 0x420016ff:0x3fc92c70 0x420015f2:0x3fc92d00 0x403751bd:0x3fc92d20 0x4201f2f1:0x3fc92d40 0x403751fd:0x3fc92d60 0x40375222:0x3fc92d80 0x403785a5:0x3fc92da0 0x42001a19:0x3fcec2f0
ELF file SHA256: a5afa40bd8899be3
Rebooting...
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0xc (RTC_SW_CPU_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x4037bb43
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3808,len:0x44c
load:0x403c9700,len:0xbec
load:0x403cc700,len:0x2920
entry 0x403c98d8
另外尝试了esp32附带的按键中断示例代码:示例->ESP32->GPIO->GPIOInterrupt 代码并修改如下:
Code: Select all
#include <Arduino.h>
struct Button {
const uint8_t PIN;
uint32_t numberKeyPresses;
bool pressed;
};
Button button1 = {0, 0, false};
Button button2 = {1, 0, false};
void ARDUINO_ISR_ATTR isr(void* arg) {
Button* s = static_cast<Button*>(arg);
s->numberKeyPresses += 1;
s->pressed = true;
}
void ARDUINO_ISR_ATTR isr() {
button2.numberKeyPresses += 1;
button2.pressed = true;
}
void setup() {
Serial.begin(115200);
pinMode(RGB_BUILTIN, OUTPUT);
pinMode(button1.PIN, INPUT_PULLUP);
attachInterruptArg(button1.PIN, isr, &button1, FALLING);
pinMode(button2.PIN, INPUT_PULLUP);
attachInterrupt(button2.PIN, isr, FALLING);
}
void loop() {
if (button1.pressed) {
Serial.printf("Button 1 has been pressed %u times\n", button1.numberKeyPresses);
if(button1.numberKeyPresses%2==0){neopixelWrite(RGB_BUILTIN,4,0,0);}
if(button1.numberKeyPresses%2==1){neopixelWrite(RGB_BUILTIN,0,0,0);}
button1.pressed = false;
}
if (button2.pressed) {
Serial.printf("Button 2 has been pressed %u times\n", button2.numberKeyPresses);
button2.pressed = false;
}
/*
static uint32_t lastMillis = 0;
if (millis() - lastMillis > 10000) {
lastMillis = millis();
detachInterrupt(button1.PIN);
Serial.println(lastMillis);
}
*/
}
正常工作了!