Skip to content

Commit 98e9f4d

Browse files
authored
Basic_Tasks sample gets watchdog resets on esp32 (#2975)
Task queue gets hammered so needs additional consideration for esp32. There's also an issue with having a `static ElapseTimer` inside an interrupt service routine because the constructor gets called on first use from ISR, which is problematic and leads to unpredictable crashing-type behaviour. Closes #2971
1 parent 10cf967 commit 98e9f4d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

samples/Basic_Tasks/app/application.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ constexpr unsigned hwTimerReportInterval{1000000}; //< How often to print hardwa
2020

2121
volatile unsigned hwTimerCount;
2222

23+
ElapseTimer hwTimer(hwTimerReportInterval);
24+
2325
/*
2426
* Analogue reader task
2527
*/
@@ -51,18 +53,25 @@ void hwTimerDelegate(uint32_t count)
5153

5254
lastCount = count;
5355
timer.start();
56+
57+
#ifdef ARCH_ESP32
58+
/*
59+
* The task queue gets hammered very hard, with no idle time.
60+
* We need to occasionally reset the watchdog timer just to let the system know everything's OK.
61+
*/
62+
WDT.alive();
63+
#endif
5464
}
5565

5666
void IRAM_ATTR hwTimerCallback()
5767
{
5868
++hwTimerCount;
5969

60-
static ElapseTimer timer(hwTimerReportInterval);
61-
if(timer.expired()) {
70+
if(hwTimer.expired()) {
6271
unsigned count = hwTimerCount;
6372
// System.queueCallback([count]() { hwTimerDelegate(count); });
6473
System.queueCallback(hwTimerDelegate, count);
65-
timer.start();
74+
hwTimer.start();
6675
}
6776
}
6877

0 commit comments

Comments
 (0)