ESP32S2 stalling 5ms every 2seconds?

PepeTheGreat
Posts: 20
Joined: Mon Sep 18, 2023 3:54 am

ESP32S2 stalling 5ms every 2seconds?

Postby PepeTheGreat » Thu Mar 28, 2024 11:25 am

Basically this issue:
https://github.com/espressif/esp-idf/issues/10055

The ESP32S2 stalls every 2 seconds for 5ms.
This is very annoying when using it for a quadcopter with 2ms cycle time.

ESP32 and ESP8266 do not have that issue.

lbernstone
Posts: 826
Joined: Mon Jul 22, 2019 3:20 pm

Re: ESP32S2 stalling 5ms every 2seconds?

Postby lbernstone » Thu Mar 28, 2024 8:29 pm

Without actual code demonstrating the issue, nobody is going to be able to help you. This is very likely a priority issue. Loop task runs at priority 1. Start a new task at priority 6 and put the led flash in that.

PepeTheGreat
Posts: 20
Joined: Mon Sep 18, 2023 3:54 am

Re: ESP32S2 stalling 5ms every 2seconds?

Postby PepeTheGreat » Thu Mar 28, 2024 9:02 pm

The actual code is in the git link. It's:

Code: Select all

void loop()  { debug_gpio = !debug_gpio; digitalWrite(MY_GPIO, debug_gpio); }
The same code works glitch-free on the old esp32.
Could this be an internal usb thing?

Edit:
I did test moving it to "task1" at priority 1. No 5ms gaps there.
I do not understand it.
Is there a source where i can see the code calling loop() ?

MicroController
Posts: 1696
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: ESP32S2 stalling 5ms every 2seconds?

Postby MicroController » Thu Mar 28, 2024 11:28 pm

PepeTheGreat wrote:
Thu Mar 28, 2024 9:02 pm
Is there a source where i can see the code calling loop() ?
Yes: https://github.com/espressif/arduino-es ... in.cpp#L69
As you can see, the 'yieldIfNecessary()' is only used on single-core ("UNICORE") ESPs/builds, like the S2.

PepeTheGreat
Posts: 20
Joined: Mon Sep 18, 2023 3:54 am

Re: ESP32S2 stalling 5ms every 2seconds?

Postby PepeTheGreat » Fri Mar 29, 2024 12:54 pm

TY
Explains it.
In the main Arduino loop, above loop() function, in the file cores/esp32/main.cpp we see yieldIfNecessary() function. It works on ESP32-S2 for example as it only has one core. Function adds a 5ms delay every two seconds. Under some specific circumstances, this causes problem with loop() execution time.

https://github.com/espressif/arduino-esp32/issues/6119

Edit:
Works perfectly since i moved the code to another priority 1 task.

Who is online

Users browsing this forum: No registered users and 34 guests