Skip to content

Instantly share code, notes, and snippets.

@nucklearproject
Created August 17, 2023 00:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nucklearproject/173e630ec0cb06e34a168a61552951c1 to your computer and use it in GitHub Desktop.
Save nucklearproject/173e630ec0cb06e34a168a61552951c1 to your computer and use it in GitHub Desktop.
ESP32 support multiples dual core FreeRTOS
#include <Arduino.h>
#include <Wire.h>
// Prueba Multitarea(Hilos)RTOS en Diferente Nucleo ESP32 by: elprofegarcia.com
TaskHandle_t Tarea0; // Tarea0 parpadeo LED 0,3 segundos
TaskHandle_t Tarea1; // Tarea1 parpadeo LED 1 Segundo
// Declaraciones previas
void loop0(void *parameter);
void loop1(void *parameter);
void setup() {
Serial.begin(115200);
xTaskCreatePinnedToCore(loop0,"Tarea_0",1000,NULL,1,&Tarea0,0); // Core 0
xTaskCreatePinnedToCore(loop1, "Tarea_1", 1000, NULL, 1, &Tarea1, 1); // Core 1
}
void loop() {
}
void loop0(void *parameter){ // Tarea0 parpadeo LED 0,3 seg ndos
while(true) {
Serial.print(" Core " + String(xPortGetCoreID()) + "\n");
delay(300);
}
}
void loop1(void *parameter){ // Tarea1 parpadeo LED 1 Segundo
while(true) {
Serial.print("Core " + String(xPortGetCoreID()) + "\n");
delay(1000);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment