#include <Arduino.h>
String core1 = "core1";
String core2 = "core2";
TaskHandle_t task1;
TaskHandle_t task2;
void setup() {
Serial.begin(115200);
xTaskCreatePinnedToCore
(
//Function, Handler, Size, ?,
Task1, /*pvTaskCode - Name of the function that contains the code*/
"task1", /*pcName - Friendly name for task*/
10000, /*usStackDepth - bytes allocated for task in stack Default(1000)*/
NULL, /*pvParameters - Input Parameter*/
1, /*uxPriority - Priority*/
&task1, /*pvCreatedTask - Pointer to the task the sketch uses for reference*/
0 /*xCoreID - Core assigned to the task*/
);
delay(500);
xTaskCreatePinnedToCore
(
Task2,
"task2",
1000,
NULL,
1,
&task2,
1
);
delay(500);
}
void Task1(void *pvParameters) {
for(;;) {
Serial.print(core1+" running on core ");
Serial.println(xPortGetCoreID());
delay(5); /*Required for wdt to acquire cycles and reset*/
}
}
void Task2(void *pvParameters) {
for(;;) {
Serial.print(core2+" running on core ");
Serial.println(xPortGetCoreID());
delay(10);
}
}
void loop() {
}