Page 1 of 1

wifi task interfering with loop() task on app core?

Posted: Mon Sep 16, 2019 2:06 pm
by ssacp148
Hey all,

I have my loop() function reading from UART2 and updating an SSD1306 OLED through I2C. This works fine and takes approximately ~35ms. However, when enabeling the loop() task seems to get pre-empted becuase when WiFi is connecting the loop() sometimes takes around 700ms instead of 35ms!

I was under the assumption that the application core (where loop() is running) is not used by any other tasks at all. I also plan to run another task on the application core for audio playback, but if the wifi task or other tasks can interfere this might become problematic.

How can I ensure I have the entire application cpu core to myself?

Re: wifi task interfering with loop() task on app core?

Posted: Mon Sep 16, 2019 2:12 pm
by boarchuz
Are you sure you're not doing anything that might be waiting for a WiFi event? I would be looking out especially for something like this in loop():

Code: Select all

while (WiFi.status() != WL_CONNECTED)
If you share your code here we might be able to spot the cause.

Re: wifi task interfering with loop() task on app core?

Posted: Mon Sep 16, 2019 3:08 pm
by ssacp148
boarchuz wrote:
Mon Sep 16, 2019 2:12 pm
Are you sure you're not doing anything that might be waiting for a WiFi event? I would be looking out especially for something like this in loop():

Code: Select all

while (WiFi.status() != WL_CONNECTED)
If you share your code here we might be able to spot the cause.
No I'm not doing anything like that in my code. I tried profiling the code inside the loop function using millis() and whenever the entire loop() function took longer than 50ms I would have it print out the time it took for each of those sections so I could get to the part causing the delay. But sometimes the LCD function would take a long time to execute and other times it was the Serial code and sometimes it the loop took well over 700ms but the sections reported that they finished executing well within 50ms, which leads me to believe that the looptask was getting pre-empted to run a higher priority task.

Re: wifi task interfering with loop() task on app core?

Posted: Wed Sep 18, 2019 7:21 am
by RoverDog
Assuming you are not running RTOS, the default core where Arduino code will run is on core 1. Core 0 is where the WiFi will run so it will not interfere with your code. As mentioned, post the code so can help you debug :geek: