Micropython on ESP32 crashes #18928
Replies: 4 comments
-
|
On ESP32, machine.Timer(0) is (on most boards) mapped to a hardware timer with a high-priority interrupt. In your loop you repeatedly start it with an extremely aggressive rate:
That combination can eventually wedge the system: the timer interrupt load + repeated reconfiguration can starve lower-priority work (including parts of the VM/GC/soft timers and even feeding the watchdog) Why this issue on Timer 0 ? The ESP32 quick reference explicitly warns that timer 0 is needed for UART.IRQ_RXIDLE and must not be used otherwise. |
Beta Was this translation helpful? Give feedback.
-
|
I set the parameters this way to demonstrate the effect. In my actual application, the program typically crashes after a few hours. UART.IRQ_RXIDLE is not used. |
Beta Was this translation helpful? Give feedback.
-
|
It would help if you explained what your application is aiming to achieve. As @Josverl has pointed out, running a timer callback at 1KHz is ambitious. Gating the callback by initialising and deinitialising the timer is inefficient. With an overview of the application we may be able to suggest other approaches. |
Beta Was this translation helpful? Give feedback.
-
|
My application now works without any issues after I switched from Timer 0 to Timer 1. My post was simply meant to point out that there is obviously a problem with the MicroPython implementation of Timer 0. My small sample program causes MicroPython to crash in such a way that even the watchdog stops working! The parameters in the program can be varied. This only results in the time until the crash taking a longer or shorter duration. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
The following program stops after a few seconds. All timers are blocked. Even the watchdog no longer works. When using Timer 1, the effect does not occur.
MicroPython v1.27.0 on 2025-12-09; Generic ESP32 module with ESP32
Beta Was this translation helpful? Give feedback.
All reactions