Hi! I am building a tower light. It has the following features:
- Battery (AXP125)
- 3 x 12 5050 Neopixel rings
- Enclosure that fits the M5Stack Core 2
- OOB, it goes into config mode (AP mode) and has a web interface to 'scan' and join a WiFi network as a client
- RESTful API for controlling the lights
I've been having random reboots of the M5Stack Core 2 using tasks. I've stripped down 99% of my code to a simple example. Any ideas how I can figure out whats causing the restarts?
Also, M5.BtnA.wasPressed() doesn't work either when the button is pressed.
My code:
#include <Arduino.h>
#include <M5Core2.h>
#include <Adafruit_NeoPixel.h>
#include "logo.h"
// create a couple task handles
TaskHandle_t TaskBtnScr;
TaskHandle_t Task2;
//BtnScrController: Displays sprite output and looks for button presses
void BtnScrController( void * pvParameters ){
for(;;){ // emulate a void loop()
M5.update();
if (M5.BtnA.wasPressed()) {
Serial.println("Button was pressed.");
delay(1000);
}
}
}
//Task2code: blinks an LED every 700 ms
void Task2code( void * pvParameters ){
Serial.print("Task2 running on core ");
Serial.println(xPortGetCoreID());
for(;;){
M5.Lcd.clearDisplay();
M5.Lcd.setCursor(0, 0);
M5.Lcd.setTextColor(WHITE);
M5.Lcd.println("task 2 code");
delay(2500);
}
}
void setup() {
M5.begin(true, true, false, true, kMBusModeOutput);
Serial.begin(115200);
// logo
M5.Lcd.pushImage(0, 0, 320, 240, (uint16_t *)gImage_logo);
delay(2500);
M5.Lcd.clearDisplay();
M5.Lcd.setCursor(0, 0);
M5.Lcd.setTextColor(WHITE);
//create a task that will be executed in the Task1code() function, with priority 1 and executed on core 0
xTaskCreatePinnedToCore(
BtnScrController, /* Task function. */
"ButtonScreenController", /* name of task. */
10000, /* Stack size of task */
NULL, /* parameter of the task */
1, /* priority of the task */
&TaskBtnScr, /* Task handle to keep track of created task */
0); /* pin task to core 0 */
delay(500);
//create a task that will be executed in the Task2code() function, with priority 1 and executed on core 1
xTaskCreatePinnedToCore(
Task2code, /* Task function. */
"Task2", /* name of task. */
10000, /* Stack size of task */
NULL, /* parameter of the task */
1, /* priority of the task */
&Task2, /* Task handle to keep track of created task */
1); /* pin task to core 1 */
delay(500);
}
void loop() {
}
Terminal:
rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:10124
load:0x40080400,len:5828
entry 0x400806a8
[E][sd_diskio.cpp:194] sdCommand(): Card Failed! cmd: 0x00
[E][sd_diskio.cpp:775] sdcard_mount(): f_mount failed: (3) The physical drive cannot work
[E][sd_diskio.cpp:194] sdCommand(): Card Failed! cmd: 0x00
Task2 running on core 1
E (19249) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (19249) task_wdt: - IDLE0 (CPU 0)
E (19249) task_wdt: Tasks currently running:
E (19249) task_wdt: CPU 0: ButtonScreenCon
E (19249) task_wdt: CPU 1: loopTask
E (19249) task_wdt: Aborting.
abort() was called at PC 0x400e7717 on core 0
ELF file SHA256: 0000000000000000
Backtrace: 0x4008a490:0x3ffbe4f0 0x4008a709:0x3ffbe510 0x400e7717:0x3ffbe530 0x40086195:0x3ffbe550 0x4000cffa:0x3ffb4600 0x40081573:0x3ffb4620 0x400d1d70:0x3ffb4640 0x400d1ee5:0x3ffb4690 0x400d15f5:0x3ffb46b0 0x400d14ca:0x3ffb46d0 0x4008b70e:0x3ffb46f0
Rebooting...
ets Jul 29 2019 12:21:46
rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:10124
load:0x40080400,len:5828
entry 0x400806a8
[E][sd_diskio.cpp:194] sdCommand(): Card Failed! cmd: 0x00
[E][sd_diskio.cpp:775] sdcard_mount(): f_mount failed: (3) The physical drive cannot work
[E][sd_diskio.cpp:194] sdCommand(): Card Failed! cmd: 0x00
Task2 running on core 1
E (19249) task_wdt: Task