esp32_use_dual_core
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
esp32_use_dual_core [2025/03/07 18:32] – bruno | esp32_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(" | + | |
- | Serial.println(xPortGetCoreID()); | + | // Create |
- | + | // with priority 1 and executed on core 0 | |
- | //create | + | |
xTaskCreatePinnedToCore( | xTaskCreatePinnedToCore( | ||
- | | + | |
- | " | + | " |
- | 10000, | + | 10000, |
- | NULL, /* parameter of the task */ | + | NULL, /* parameter of the task */ |
- | 1, /* priority of the task */ | + | 1, /* priority of the 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(" | ||
- | Serial.println(xPortGetCoreID()); | ||
for(;;){ | for(;;){ | ||
- | Serial.print(" | + | Serial.print(" |
+ | Serial.print(xPortGetCoreID()); | ||
+ | Serial.print(":" | ||
+ | Serial.println(i++); | ||
delay(1000); | delay(1000); | ||
} | } | ||
} | } | ||
+ | |||
void loop() { | void loop() { | ||
- | Serial.print(" | + | Serial.print(" |
- | delay(700); | + | Serial.print(xPortGetCoreID()); |
+ | Serial.print(":" | ||
+ | Serial.println(i++); | ||
+ | delay(300); | ||
} | } | ||
+ | |||
</ | </ |
esp32_use_dual_core.txt · Last modified: 2025/03/07 19:41 by bruno