0% found this document useful (0 votes)
16 views3 pages

Ex8 Task Scheduling Process Using ESP32 Dual Core

The document outlines a task scheduling process using an ESP32 Dual Core with FreeRTOS to control two LEDs. It details the components required, basic functions, and provides code for creating two tasks that independently blink the LEDs at different intervals while displaying the core ID on the serial monitor. The output confirms that the LEDs turn on and off according to the specified timing and task scheduling process.

Uploaded by

226004023
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views3 pages

Ex8 Task Scheduling Process Using ESP32 Dual Core

The document outlines a task scheduling process using an ESP32 Dual Core with FreeRTOS to control two LEDs. It details the components required, basic functions, and provides code for creating two tasks that independently blink the LEDs at different intervals while displaying the core ID on the serial monitor. The output confirms that the LEDs turn on and off according to the specified timing and task scheduling process.

Uploaded by

226004023
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Ex.

No:8
Task scheduling process using ESP32 Dual Core with FreeRTOS

Aim:

Create two tasks and turn ON/OFF the LED based on task scheduling process using ESP32 and
FreeRTOS
Components Required:
1. One ESP32 board
2. Two LEDs
Prerequisite:
1. Connect the positive leg of LED1 to the GPIO Pin 32 in ESP32 board.
2. Connect the negative leg of LED1 to the GND pin in ESP32 board.
3. Connect the positive leg of LED2 to the GPIO Pin 25 in ESP32 board.
4. Connect the negative leg of LED2 to the GND pin in ESP32 board.

Block Diagram:

1
Basic Functions:

 TaskHandle_t – Define a task handle


 xTaskCreatePinnedToCore() – to create the task for core 0 and core 1
 It takes sevent parameters
o Name of the function
o Name of the task
o Stack size
o Task Input parameter
o Priority of task (0 is the lowest priority)
o Task handle
o Core ID
 Task1code() - code for LED to blink every 0.5 secs
o This function takes in a single global argument called a parameter.
o Display the core ID on serial monitor for the running task
o Infinite loop can be used to blink the LED with delay 0.5 seconds.
 pinMode( )

Specific pin number is set as the INPUT or OUTPUT in the pinMode () function
Syntax:
pinMode (pin, mode)
 digitalRead () function will read the HIGH/LOW value from the digital pin
 digitalWrite () function is used to set the HIGH/LOW value of the digital pin

Code:
TaskHandle_t Task1;
TaskHandle_t Task2;

const int led_1 = 32;


const int led_2 = 25;

void setup() {
Serial.begin(115200);
pinMode(led_1, OUTPUT);
pinMode(led_2, OUTPUT);

xTaskCreatePinnedToCore(Task1code,"Task1",10000,NULL,1,&Task1,0);
delay(500);

xTaskCreatePinnedToCore(Task2code,"Task2",10000,NULL,1,&Task2,1);
delay(500);
}

void Task1code( void * parameter ){


Serial.print("Task1 is running on core ");
Serial.println(xPortGetCoreID());

for(;;){
digitalWrite(led_1, HIGH);
delay(500);
2
Ex.No:8
Task scheduling process using ESP32 Dual Core with FreeRTOS

digitalWrite(led_1, LOW);
delay(500);
}
}

void Task2code( void * parameter ){


Serial.print("Task2 is running on core ");
Serial.println(xPortGetCoreID());

for(;;){
digitalWrite(led_2, HIGH);
delay(1000);
digitalWrite(led_2, LOW);
delay(1000);
}
}

void loop() {

Working:
 Two separate tasks are created and running independently.
 Task scheduling function controls the LED blinking process for every 0.5 seconds and
displays the core ID on serial monitor.
 Serial monitor in the Arduino IDE is used for debugging purpose.

Output:

The LED is on or off every 0.5 seconds according to the task scheduling process, and the core ID
is displayed on the serial monitor

You might also like