WIFI task messes up timer interrupts

tremon36
Posts: 1
Joined: Mon Jan 16, 2023 7:20 pm

WIFI task messes up timer interrupts

Postby tremon36 » Mon Jan 16, 2023 7:42 pm

I'm creating an application where I generate a PWM signal using a hardware timer, using ESP IDF, and an ESP32 board.
The application has a few other FreeRTOS tasks, and when running everything without internet connection it works just fine.
However, I need to periodically send some data through MQTT, and for that, I'm using a modified version of the provided MQTT via TCP example.
The problem is that when I add this networking task, the PWM signal gets messed up. However, I don't understand why, as it is produced with a hardware timer and interrupts. It seems like the network task is either

a) disabling all interrupts when it runs
b) generating very long interrupts delaying the execution of timer interrupts
c) The networking task is using the timer internally, which doesn't seem the case, as I have read that only TIMER_GROUP_1 is used by internal components

I can provide some code if you think it might help to solve the issue.

Some details:
The used timer is TIMER_1 from TIMER_GROUP_0
The MQTT task has a period of 1 second, and it seems like only when it runs the PWM signal gets messed up

Things I've tried so far:
  • Changing all the FreeRTOS tasks to run on core 0, then setting TCP/IP core affinity to core 1
    Changing the hardware timer used to generate the PWM signal
    Changing the timer interrupt priority to level 3 (the highest callable from a C context)
    Reducing the MQTT task period
At this point I don't know what else to try, or how to diagnose the problem. Any ideas on what it might be? Thank you

ajosev5
Posts: 5
Joined: Wed Mar 29, 2023 2:38 am

Re: WIFI task messes up timer interrupts

Postby ajosev5 » Wed Mar 29, 2023 2:43 am

Hi, I seem to have a similar problem with the WiFi task clobbering my timer I'm using in another task, while WiFi is connecting. It appears to be causing my timer expired interrupt/callback to execute. Honestly, a pretty egregious bug. I found this by putting a LOG in my timer callback - it executes prematurely, right after "wifi: state: init -> auth (b0)".

Did you find a solution to this?

Who is online

Users browsing this forum: Bing [Bot], ESP_Sprite and 199 guests