具有以下代码的M5Atom精简版在引导后关闭。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精简版是一个带有ESP32-PICO-D4双核微处理器的模块。
我通过串行监视器收到以下消息。
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发布于 2021-08-18 10:45:09
您还没有创建您试图使用的信号量。您需要首先在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);
}为简单起见,省略了错误处理。
https://stackoverflow.com/questions/68830815
复制相似问题