Using dual-core microcontrollers, such as the ESP32 or RP2040, allows for parallel processing by running tasks on two independent processors. By taking advantage of Core 1, for non-time-critical, processor-intensive tasks, like sensor processing, display updates or filtering algorithms, you can improve the responsiveness of time-critical tasks, such as I/O operations, networking or user interface functions.

image.png

core seperation

The main idea behind utilizing dual core microcontrollers is to separate tasks. Core 0 is responsible for all interrupt, communication stack, and other latency sensitive tasks, where as Core 1 is responsible for all non-time critical, processor intense, or blocking tasks.

This separation of tasks reduces bottlenecks from occurring, and thus aide in eliminating watchdog processor reset occurrences. On platforms such as the ESP32 (FreeRTOS based platform), tasks can be pinned to specific cores. You can do this with the API call xTaskCreatePinnedToCore() to assign a task(s) to a specific core, which will improve execution predictability, and reduce contention created by other tasks.

image.png

inter-core communication

Inter-core communication is essential. Shared Global Variables should be avoided through the use of Queues, Semaphores or Mutexes to prevent Race Conditions Always protect your shared resources with synchronization primitives to maintain the integrity of the data.

Also, minimize the dependencies between tasks on the two cores as much as possible. The more independent a task is of another, the better it will run on its designated core. For example, if you were to have a single processor do all of the pre-processing of sensor data and then only send to Core 0 the final post-processed data; this would result in less overhead (communication) between two processed sets of data.

image.png

multi-core debugging

Debugging is quite difficult on multi-core systems. Multi-core systems contain many more types of problems which make debugging more difficult than single-core systems, i.e., Dead Locks and Priority Inversion etc… As a rule, you should verify that your application is functioning prior to debugging when transferring from single to multi-core.

You also will want to monitor CPU Utilization in relation to Core 1, Core 1 may be underutilized due to Priority not being distributed evenly. Proper scheduling of processes and testing of processes should ensure the efficient utilization of all cores.

#microcontrollers#

esp32 #esp32#

#microcontrollers#
#esp32#
MCU

No comments yet. Be the first to comment!