I just started with freertos example in arduino on ESP32, i noticed that most of exmaple have xTaskCreatePinnedToCore used to create task. This DHT sensor lib als0 uses xTaskCreatePinnedToCore . i would like to know difference between xTaskCreatePinnedToCore and xTaskCreate ? Which should be used ? how does it effects working if i have multiple task ?
ESP32 xTaskCreatePinnedToCore usage in a class
[usb_device_uac] assert failed: xTaskCreatePinnedToCore freertos_tasks_c_additions.h (AEGHB-674)
Why was xTaskCreatePinnedToCore removed from the latest release?
Programing error, xTaskCreatePinnedToCore + was not declared in this scope
You have created 2 tasks with priority 0 which is the lowest priority in the system. ESP IDF implicitly creates a several other tasks (many with higher priorities) and your tasks have to share CPU cores with those.
Firstly there are 2 idle tasks (one per core) with priority 0. Since the priorities of your tasks and the idle tasks are equal, they share core time equally (50/50). So the scheduler rotates them on each core every 10 ms by default, which is quite likely the source of your flickering.
Then there are other, higher priority tasks which ESP IDF creates. If you enabled WiFi then its driver runs in a high priority (23 by default) task. The High Resolution Timer service creates its own high priority (22) task. If you've enabled TCP/IP networking, this has runs in a high priority task; etc. Granted, those tasks don't take up much core time if you don't use their services. But they take up some.
So, in short you don't get exclusive use of a CPU core. You can cut out the idle tasks by raising your priority (by the way, the Task Watchdog Timer will complain and reset the system soon if you don't let the idle task run at all; unless you disable it). You can also cut out all other tasks by raising your priority to the maximum, but in any real embedded system those other tasks do something useful ;)
Might be to do with the fact that ESP32 is SMP.
https://www.freertos.org/single-core-amp-smp-rtos-scheduling.html
Not 100% sure but the Freertos task scheduler needs to run somewhere, it will only run on 1 core, subsequently stopping both tasks as it figures out what to do. So it will have to pause one of the task on a core. Without the delay then the scheduler may struggle.
This is a bit of guess. Might point you in the right direction.