Section 8: ESP32 Dual Core Setup

The advanced features such as StallGuard can be purchased in our PDF guide here.

 

Before we go further into FastAccelStepper, let’s set up the dual core capability of the ESP32, because it may confuse you in the sketch. Here is the basic overview.

The ESP32 has two cores. For best performance, we need the motor functions to run on one core, and the WiFi functions to run on the other core.

By default, all Arduino code runs on Core 1 (including the WiFi processes). So, we will create Core 0. To create Core 0, we do this:

  xTaskCreatePinnedToCore(
MotorTask
, "MotorTask"
, 1024 * 4
, NULL
, 3
, NULL
, 0);

Next, let’s create the function to run on this core, it needs to be named MotorTask because that’s what we named it above.

Here we have our function running in a loop on core 0 only. This is where the motor will run, ensuring it only runs on Core 0. The while(true) creates an infinite loop.

void MotorTask(void *pvParameters) {
while(true) {

NEXT SECTION: 9

 Course Sections:

Advanced Sections:

Back to blog

Leave a comment