Skip to main content

Posts

Showing posts with the label FreeRTOS

ESP32 Multitasking: Assigning FreeRTOS Tasks to Specific Cores (Core 0 vs Core 1)

  If you have ever pushed an ESP32 to its limit with heavy sensor aggregation or cryptographic calculations while maintaining a Wi-Fi connection, you have likely encountered the infamous   Task Watchdog Got Triggered   error or unexplained network disconnects. The ESP32 is a dual-core system, yet many firmware engineers treat it like an Arduino Uno (single-core), dumping all logic into the main loop or generic FreeRTOS tasks. This results in the "Application" code fighting for CPU cycles with the "Protocol" (Wi-Fi/Bluetooth) stack. When your blocking code wins, the Wi-Fi stack starves, the watchdog bites, and the system resets. To build industrial-grade firmware, you must explicitly leverage the symmetric multiprocessing (SMP) capabilities of the ESP32 by pinning tasks to specific cores. The Root Cause: PRO_CPU vs. APP_CPU The ESP32 architecture consists of two Tensilica Xtensa LX6 microprocessors: Core 0 (Protocol CPU / PRO_CPU):  By default, the ESP-IDF (and Ardui...