带有互斥量的 M5Atom 已关闭
M5Atom with mutex is down
带有以下代码的M5Atom Lite在开机后就宕机了。
M5宕机后继续重启
这段代码是针对多任务和互斥的简单测试。
#include <Arduino.h>
SemaphoreHandle_t xMutex = NULL;
volatile int a = 0;
void subprocess(void *pvParameters)
{
for (;;)
{
if (xSemaphoreTake(xMutex, (portTickType)1000) == pdTRUE)
{
Serial.println(2 * a);
a++;
xSemaphoreGive(xMutex);
}
delay(1000);
}
}
void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
// Begin task with Core 0
xTaskCreatePinnedToCore(subprocess, "subprocess", 4096, NULL, 1, NULL, 0);
}
void loop()
{
if (xSemaphoreTake(xMutex, (portTickType)1000) == pdTRUE)
{
Serial.println(2 * a + 1);
a++;
xSemaphoreGive(xMutex);
}
delay(1000);
}
M5Atom Lite 是一款带有 ESP32-PICO-D4 双核 MCU 的模组。
我通过串行监视器收到以下消息。
Rebooting...
ets Jun 8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 188777542, 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
/home/runne/rh/owmoer/kr/uensnpe3r2/-waorrdku/iensop-3l2i-ba-rbduuiilndoe-rl/iebs-pb3u2i-ladredru/iensop-3l2i-ba-rbduuiilndoe-rl/ib--uil/co/eoneidf/frmpotes/s/fueec:14s/ (eQe.ce1en2 (xQeeuive)- assertefvi)-d!
ebrt f) was c
eled a) PC 0xalled 51 oC 0xre 1
ELF file SHA256: 0000000000000000
Backtrace: 0x40084ea0:0x3ffb1f10 0x40085115:0x3ffb1f30 0x40085e51:0x3ffb1f50 0x400d0cc8:0x3ffb1f90 0x400d1f79:0x3ffb1fb0 0x40086125:0x3ffb1fd0
您尚未创建要使用的信号量。您需要先在 setup()
中创建它。例如,假设您想要一个由 xSemaphoreCreateBinary()
:
创建的二进制信号量
void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
xMutex = xSemaphoreCreateBinary();
// Begin task with Core 0
xTaskCreatePinnedToCore(subprocess, "subprocess", 4096, NULL, 1, NULL, 0);
}
为简单起见省略了错误处理。
带有以下代码的M5Atom Lite在开机后就宕机了。 M5宕机后继续重启
这段代码是针对多任务和互斥的简单测试。
#include <Arduino.h>
SemaphoreHandle_t xMutex = NULL;
volatile int a = 0;
void subprocess(void *pvParameters)
{
for (;;)
{
if (xSemaphoreTake(xMutex, (portTickType)1000) == pdTRUE)
{
Serial.println(2 * a);
a++;
xSemaphoreGive(xMutex);
}
delay(1000);
}
}
void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
// Begin task with Core 0
xTaskCreatePinnedToCore(subprocess, "subprocess", 4096, NULL, 1, NULL, 0);
}
void loop()
{
if (xSemaphoreTake(xMutex, (portTickType)1000) == pdTRUE)
{
Serial.println(2 * a + 1);
a++;
xSemaphoreGive(xMutex);
}
delay(1000);
}
M5Atom Lite 是一款带有 ESP32-PICO-D4 双核 MCU 的模组。
我通过串行监视器收到以下消息。
Rebooting...
ets Jun 8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 188777542, 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
/home/runne/rh/owmoer/kr/uensnpe3r2/-waorrdku/iensop-3l2i-ba-rbduuiilndoe-rl/iebs-pb3u2i-ladredru/iensop-3l2i-ba-rbduuiilndoe-rl/ib--uil/co/eoneidf/frmpotes/s/fueec:14s/ (eQe.ce1en2 (xQeeuive)- assertefvi)-d!
ebrt f) was c
eled a) PC 0xalled 51 oC 0xre 1
ELF file SHA256: 0000000000000000
Backtrace: 0x40084ea0:0x3ffb1f10 0x40085115:0x3ffb1f30 0x40085e51:0x3ffb1f50 0x400d0cc8:0x3ffb1f90 0x400d1f79:0x3ffb1fb0 0x40086125:0x3ffb1fd0
您尚未创建要使用的信号量。您需要先在 setup()
中创建它。例如,假设您想要一个由 xSemaphoreCreateBinary()
:
void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
xMutex = xSemaphoreCreateBinary();
// Begin task with Core 0
xTaskCreatePinnedToCore(subprocess, "subprocess", 4096, NULL, 1, NULL, 0);
}
为简单起见省略了错误处理。