|
本帖最后由 lmn2005 于 2022-6-2 19:19 编辑
参考https://blog.csdn.net/weixin_42880082/article/details/120882798使用esp32内部硬件定时器,结果大约每隔4、5秒就会重启一次:
ets Jun 8 206 00:22:57
rst:0x (POWERON_RESET)bot:0x7 (SPI_FAST_FLASH_BOT)
configsip: 0, SPWP:0xee
clk_drv:0x00,_rv:0x00,d_drv:0x00,c0_drv:0x0,hd_drv:0x00,wp_dv:0x00
modeIO, clc div:1
load:0x3fff001,len:4
load:0x3fff001c,en:1128
load:0x400700,len:10124
load:0x0080400,len:5856
enry 0x40006a8
haha
1
haha
1
haha
1
haha
1
E (10102) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (10102) task_wdt: - IDLE0 (CPU 0)
E (10102) task_wdt: Tasks currently running:
E (10102) task_wdt: CPU 0: loopTask
E (10102) task_wdt: Aborting.
abort() was called at PC 0x400d43b3 on core 0
ELF file SHA256: 0000000000000000
Backtrace: 0x4008498c:0x3ffbe2b0 0x40084be9:0x3ffbe2d0 0x400d43b3:0x3ffbe2f0 0x400825aa:0x3ffbe310 0x400d0b24:0x3ffb1f90 0x400d1f79:0x3ffb1fb0 0x40085b55:0x3ffb1fd0
Rebooting...
ets Jun 8 2016 00:22:57
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
modeIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1128
load:0x40078000,len:10124
load:0x40080400,len:5856
entry 0x400806a8
haha
1
haha
1
这是为什么?
源代码如下:
#include <Arduino.h>
hw_timer_t *tim1 = NULL;
int tim1_IRQ_count = 0;
void ICACHE_RAM_ATTR tim1Interrupt() //中断服务函数
{
Serial.println("haha");
tim1_IRQ_count++;
Serial.println(timerAlarmEnabled(tim1));
}
void setup()
{
Serial.begin(115200);
tim1 = timerBegin(0, 80, true); // 80MHZ, ESP32主频80MHz
timerAttachInterrupt(tim1, tim1Interrupt, true);
timerAlarmWrite(tim1, 1000000ul, true);
timerAlarmEnable(tim1); // 使能定时器
}
void loop()
{
if (tim1_IRQ_count > 10)
{
Serial.println("timer------");
tim1_IRQ_count = 0;
}
}
|
|