Comments on: How to use ESP32 Dual Core with Arduino IDE https://randomnerdtutorials.com/esp32-dual-core-arduino-ide/ Learn ESP8266, ESP32, Arduino, and Raspberry Pi Thu, 27 Feb 2025 02:20:51 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: David K https://randomnerdtutorials.com/esp32-dual-core-arduino-ide/#comment-1011415 Thu, 27 Feb 2025 02:20:51 +0000 https://randomnerdtutorials.com/?p=74416#comment-1011415 Hi, please pardon some elementary questions from someone new to all this.

Let me start with the xTaskCreatePinnedToCore definition:

xTaskCreatePinnedToCore(
Task1code, /* Task function. /
“Task1”, /
name of task. /
10000, /
Stack size of task /
NULL, /
parameter of the task /
1, /
priority of the task /
&Task1, /
Task handle to keep track of created task /
0); /
pin task to core 0 */

Questions:
1) What are the requirements for the Stack size? Does a larger task ( i.e. more code and variables) require a larger Stack size?
2) Under what circumstances would the parameter of the task not be NULL?
3) What are all the possible values of the priority of the task?

Regarding the declaration of the task:

void Task1code( void * pvParameters )

1) What are pvParameters?
2) Coulld Task1code have different arguments, i.e. something other than pvParameters?

Thanks in advance!

]]>
By: Augusto https://randomnerdtutorials.com/esp32-dual-core-arduino-ide/#comment-985726 Sat, 23 Nov 2024 20:37:32 +0000 https://randomnerdtutorials.com/?p=74416#comment-985726 In reply to Harry.

I agree with the 1st statement but… if you look at delay function code, behind the curtains it calls vTaskDelay.
So, I suppose it is safe to use 😉
<framework-arduinoespressif32/cores/esp32/esp32-hal-misc.c>
void delay(uint32_t ms)
{
vTaskDelay(ms / portTICK_PERIOD_MS);
}
Cheers

]]>
By: Rui Miguel Elias https://randomnerdtutorials.com/esp32-dual-core-arduino-ide/#comment-931802 Sat, 29 Jun 2024 01:27:37 +0000 https://randomnerdtutorials.com/?p=74416#comment-931802 In reply to ega.

HI, this function “disablecore0wdt();” solved it. Thank you very much.

]]>
By: PuceBaboon https://randomnerdtutorials.com/esp32-dual-core-arduino-ide/#comment-904855 Tue, 09 Apr 2024 23:21:14 +0000 https://randomnerdtutorials.com/?p=74416#comment-904855 In reply to shankar.

Shankar,

At the very end of your endless while() loop, add a vTaskDelay(xDelay); and define your xDelay as something like:-

const TickType_t xDelay = (10 / portTICK_PERIOD_MS);

The delay will stop your task without blocking other processes and thus give the system a chance to run something else (in this case, WiFi, which runs on core-0 by default).

]]>
By: Philippe https://randomnerdtutorials.com/esp32-dual-core-arduino-ide/#comment-877029 Sun, 10 Dec 2023 12:24:20 +0000 https://randomnerdtutorials.com/?p=74416#comment-877029 Hello Sara and Rui,

This is an excellent page, which has helped me to understand the importance of both hearts and how to manage them. It’s a very good introduction to the subject.
In your example, is it normal for the priority of both tasks to be 1?

]]>
By: shankar https://randomnerdtutorials.com/esp32-dual-core-arduino-ide/#comment-862870 Thu, 28 Sep 2023 11:31:43 +0000 https://randomnerdtutorials.com/?p=74416#comment-862870 In reply to Sara Santos.

sometimes error also coming
E (31208) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (31208) task_wdt: – IDLE (CPU 0)
E (31208) task_wdt: Tasks currently running:
E (31208) task_wdt: CPU 0: Task1
E (31208) task_wdt: CPU 1: IDLE
E (31208) task_wdt: Aborting.

]]>
By: shankar https://randomnerdtutorials.com/esp32-dual-core-arduino-ide/#comment-862866 Thu, 28 Sep 2023 11:27:46 +0000 https://randomnerdtutorials.com/?p=74416#comment-862866 In reply to Sara Santos.

hello can you wtite the code for to plot the graphs in between two cores
TaskHandle_t Task1;
TaskHandle_t Task2;

// LED pins
const int led1 = 2;
const int led2 = 4;

void setup() {
Serial.begin(115200);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);

//create a task that will be executed in the Task1code() function, with priority 1 and executed on core 0
xTaskCreatePinnedToCore(
Task1code, /* Task function. /
“Task1”, /
name of task. /
10000, /
Stack size of task /
NULL, /
parameter of the task /
1, /
priority of the task /
&Task1, /
Task handle to keep track of created task /
0); /
pin task to core 0 */
//delay(50);

//create a task that will be executed in the Task2code() function, with priority 1 and executed on core 1
xTaskCreatePinnedToCore(
Task2code, /* Task function. /
“Task2”, /
name of task. /
10000, /
Stack size of task /
NULL, /
parameter of the task /
1, /
priority of the task /
&Task2, /
Task handle to keep track of created task /
1); /
pin task to core 1 */
// delay(50);
}

//Task1code: blinks an LED every 1000 ms
void Task1code( void * pvParameters ){
Serial.print(“Task1 running on core “);
Serial.println(xPortGetCoreID());
unsigned long cnt=0;
while(1){
/digitalWrite(led1, HIGH);
delay(1000);
digitalWrite(led1, LOW);
/
// delay(10);
Serial.println(“intask1”);
//Serial.println(cnt++);
}
}

//Task2code: blinks an LED every 700 ms
void Task2code( void * pvParameters ){
Serial.print(“Task2 running on core “);
Serial.println(xPortGetCoreID());
unsigned long cntt =0;
while(1){
/digitalWrite(led2, HIGH);
delay(700);
digitalWrite(led2, LOW);
delay(700);
/
Serial.println(“intask2”);
//Serial.println(cntt++);
}
}

void loop() {

}//////only task one printing on the sceen not working on the task2

]]>
By: Sara Santos https://randomnerdtutorials.com/esp32-dual-core-arduino-ide/#comment-851293 Thu, 27 Jul 2023 09:09:52 +0000 https://randomnerdtutorials.com/?p=74416#comment-851293 In reply to osama.

Hi.
Yes.
That’s right.
Thanks.
Regards,
Sara

]]>
By: osama https://randomnerdtutorials.com/esp32-dual-core-arduino-ide/#comment-850867 Wed, 26 Jul 2023 18:35:14 +0000 https://randomnerdtutorials.com/?p=74416#comment-850867 Great tutorial , but I have a note I think you should add it above.
in esp32 data sheet , it sais that core 0 is used for wifi and bluetooth communtcation and other os stuff and you shouldn’t use it unless it is very important task with caution , otherwise the cpu will panic

]]>
By: jeebs https://randomnerdtutorials.com/esp32-dual-core-arduino-ide/#comment-835392 Fri, 19 May 2023 15:38:49 +0000 https://randomnerdtutorials.com/?p=74416#comment-835392 In reply to dev.

i got this too and i am very stuck

]]>