- A tight loop that never yields starves the IDLE task. Add vTaskDelay or yield; do not spin on GPIO polls in app_main forever.
- Blocking in a high-priority task while Wi-Fi or lwIP needs CPU looks like a random TWDT panic.
- Long critical sections and printf floods in ISR context also trip the watchdog.
- If you disabled the watchdog to ‘make it run’, you only hid a scheduling bug. Fix the wait path.
Short answer
ESP32 hits the task watchdog in a simple loop. What usually causes it?
中文
短答
简单循环里 ESP32 触发任务看门狗,常见原因?
- 死循环不让出 CPU,IDLE 饿死。加 vTaskDelay 或 yield,不要在 app_main 里空转扫 GPIO。
- 高优先级任务堵死,Wi-Fi / lwIP 抢不到时间,也会像随机 TWDT。
- 过长临界区、在中断里狂打日志,同样会踢看门狗。
- 关掉看门狗只是藏调度问题。把等待路径改对。