Hi everyone,
I’m currently working on an ESP32 project (within an Arm-based development ecosystem) and I’ve hit a bit of a bottleneck with multi-core task scheduling.
The goal is to run two concurrent tasks:
High-Frequency Sensor Loop: Fast, deterministic reads that shouldn't be interrupted.
Network Communication: Wi-Fi + MQTT stack running at a different priority level.
On paper, FreeRTOS should handle this easily, but in practice, I’m seeing significant timing jitter and dropped sensor samples as soon as the network task becomes active. I’ve experimented with task priorities and vTaskDelay, but I’m still struggling to prevent the netwwork stack from starving the high frequency loop...
vTaskDelay
Since the ESP32 is dual-core, I’m looking for the best way to:
Effective Core Affinity: How should I pin tasks to Core 0 vs Core 1 to avoid interference from the Wi-Fi/BT stack (which usually sits on Core 0)?
Non-Blocking Synchronization: What’s the most efficient way to pass data between these tasks (Queues vs. Task Notifications) without introducing latency into the sensor loop???
Interrupt Handling: Should I move the sensor read to a High-Level Interrupt (Level 4/5) to bypass the RTOS scheduler entirely?
If anyone has tackled similar multi-core scheduling challenges, what design patterns worked for you? Are there specific 'gotchas' with the dual-core scheduling that I should be aware of?
Any pointers or code snippets would be greatly appreciated. Thanks!
Espressif Docs: Multi-Core Task Scheduling
FreeRTOS: Task Priorities and Starvation