User Tools

Site Tools


esp32_use_dual_core

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
esp32_use_dual_core [2025/03/07 18:32] brunoesp32_use_dual_core [2025/03/07 19:41] (current) bruno
Line 3: Line 3:
 <code c> <code c>
 TaskHandle_t Task1; TaskHandle_t Task1;
 +
 +// Variable partagée par les deux process
 +
 +int i = 0;
  
 void setup() { void setup() {
 + 
   Serial.begin(115200);    Serial.begin(115200); 
 + 
   // By default, Arduino sketches run on core 1   // By default, Arduino sketches run on core 1
-  Serial.print("By default: running on core "); +  
-  Serial.println(xPortGetCoreID()); +  // Create a task that will be executed in the Task1code() function 
- +  // with priority 1 and executed on core 0
-  //create a task that will be executed in the Task1code() functionwith priority 1 and executed on core 0+
   xTaskCreatePinnedToCore(   xTaskCreatePinnedToCore(
-                    Task1code,   /* Task function. */ +    Task1code,   /* Task function. */ 
-                    "Task1",     /* name of task. */ +    "Task1",     /* name of task. */ 
-                    10000,       /* Stack size of task */ +    10000,       /* Stack size of task */ 
-                    NULL,        /* parameter of the task */ +    NULL,        /* parameter of the task */ 
-                    1,           /* priority of the task */ +    1,           /* priority of the task */ 
-                    &Task1,      /* Task handle to keep track of created task */ +    &Task1,      /* Task handle to keep track of created task */ 
-                    0);          /* pin task to core 0 */     +    0);          /* pin task to core 0 */ 
- +
-//  delay(500);  + 
-  +
 void Task1code( void * pvParameters ){ void Task1code( void * pvParameters ){
-  Serial.print("Task1 running on core "); 
-  Serial.println(xPortGetCoreID()); 
   for(;;){   for(;;){
-    Serial.print("1");+    Serial.print("Core "); 
 +    Serial.print(xPortGetCoreID()); 
 +    Serial.print(":"); 
 +    Serial.println(i++);
     delay(1000);     delay(1000);
   }    } 
 } }
 + 
 void loop() { void loop() {
-  Serial.print("0"); +  Serial.print("Core "); 
-  delay(700);+  Serial.print(xPortGetCoreID()); 
 +  Serial.print(":"); 
 +  Serial.println(i++); 
 +  delay(300);
   }   }
 +
 </code> </code>
esp32_use_dual_core.txt · Last modified: 2025/03/07 19:41 by bruno