Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timer on ESP32 hangs the chip if used with WiFi and a too fast rate for the Timer (ex 15mS), not happening on ESP8266. #2943

Closed
profjmer opened this issue Feb 5, 2025 · 4 comments

Comments

@profjmer
Copy link

profjmer commented Feb 5, 2025

On a ESP8266 I have an app, that is running an FSM by a Timer each 100uSec. (running fine with: Wifi, webserver, i2c, spi ...)

On an ESP32 a single bit toggle by a Timer can work at the same rate in Basic_Blink, but in Basic_Wifi sample, a rate faster than 15mS will hang the system.

Here is an extract of the test code:

int i;
IRAM_ATTR void systick()
{
	if(i++>9){
		digitalWrite(22,!digitalRead(22));  // this is an LED on my ESP32 Board TTGO V1.3
		i=0;
	}
}

in void init()
pinMode(22,OUTPUT);
pulse_timer.initializeMs<15>(systick).start();

ESP8266 has only one core and is performing better with Timer and WiFi
Esp32 has two cores, but Timer seems to interfere with WiFi at a rate too fast.
Is it something that can be improved in ESP32 ? (by not using the same core that WiFi uses ? or else)

@mikee47
Copy link
Contributor

mikee47 commented Feb 5, 2025

Fast timers are very inefficient on the esp32 due to the interrupt and software servicing overhead. Perhaps look for a way to use the hardware directly, e.g. LEDC or other modules.

Sming builds with CONFIG_FREERTOS_UNICORE=y by default. See #2916 et. al.

@mikee47
Copy link
Contributor

mikee47 commented Feb 5, 2025

NB. Are you using HardwareTimer? This has a lower software overhead as the callback is invoked in interrupt context. Software timers use the task queue which slows things down.

@mikee47
Copy link
Contributor

mikee47 commented Feb 5, 2025

See also #2445 (comment)

@profjmer profjmer closed this as completed Feb 5, 2025
@mikee47
Copy link
Contributor

mikee47 commented Feb 7, 2025

@profjmer Be interested to hear about any solution you come up with for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants