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

ssacp148
Posts: 9
Joined: Sun Aug 25, 2019 9:21 pm

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

Postby ssacp148 » Mon Sep 16, 2019 2:06 pm

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?

boarchuz
Posts: 132
Joined: Tue Aug 21, 2018 5:28 am

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

Postby boarchuz » 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.

ssacp148
Posts: 9
Joined: Sun Aug 25, 2019 9:21 pm

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

Postby ssacp148 » Mon Sep 16, 2019 3:08 pm

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.

RoverDog
Posts: 8
Joined: Fri Aug 30, 2019 3:38 am

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

Postby RoverDog » Wed Sep 18, 2019 7:21 am

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:

Who is online

Users browsing this forum: No registered users and 6 guests