I was working with ESP-IDF and I want to run two task at the same time of different cores of ESP32, So I used
xTaskCreatePinnedToCore(sensorsTask, "Sensor" , 5000, 0, 0, &sensorTaskHandler,0); xTaskCreatePinnedToCore(storageTask, "Storage", 5000, 0, 0, &storageTaskHandler,1);
and the corrosponding tasks are:
`void storageTask(){
for(;;){
gpio_set_level(4, 1);
gpio_set_level(2, 0);
}
}
void sensorsTask(){
for(;;){
gpio_set_level(2, 1);
gpio_set_level(4, 0);
}
}`
if both tasks are running really parallel then both LEDs should be ON all the time, but in real Both LEDs were flickering, which mean that both task are running one by one. i-e "SensorTask" runs on core 0 first **THEN **"storageTask" runs on core 1. Now if we add vTaskDelay(1) in both tasks it works fine, but the question is if both tasks are running simultaneously and independent of each other then why LEDs were flickering, and what is the need of adding delay. keeping the thing in mind that this delay actually help to switch b/w tasks, but in this case we have two cores and two task so no switching is really required.
I am trying to run two tasks on two cores of ESP-32 at the same time but its feels that they are running one by one as in single core microcontrollers