-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Description
Basic Infos
- This issue complies with the issue POLICY doc.
- I have read the documentation at readthedocs and the issue is not addressed there.
- I have tested that the issue is present in current master branch (aka latest git).
- I have searched the issue tracker for a similar issue.
- If there is a stack dump, I have decoded it.
- I have filled out all fields below.
Platform
- Hardware: [NodeMcu (ESP12E - ESP12F)]
- Core Version: [b551992]
- Development Env: [Eclipse/Sloeber]
- Operating System: [Windows]
Settings in IDE
- Module: [Nodemcu]
- Flash Mode: [dio]
- Flash Size: [4MB]
- lwip Variant: [v2 Lower Memory]
- Reset Method: [ck|nodemcu]
- Flash Frequency: [40Mhz]
- CPU Frequency: [80Mhz|160MHz]
- Upload Using: [SERIAL]
- Upload Speed: [115200]
Problem Description
Long latency of the loop function (887ms) due WiFi connection activity. There are no change of the issue changing the lock setting from 80Mhz to 160Mhz.
The issue occur after a while that WiFi.begin is called and just before the "WIFI_EVENT_STAMODE_CONNECTED" event.
Use the sketch below to recreate the issue. The sketch also use some pin to allow the tracing via an hardware logic analizer. The two attached pictures show the behavior with 80Mhz and 160Mhz clock settings.
In the two pictures, the 2nd pulse in the track "SETUP" is the WiFi.begin call.
The track "LOOP" is generated by loop function that toggle a pin every 2ms (see the sketch).
The issue is active in the commits: 968d6fc and the last b551992
Could be related to: #4891
MCVE Sketch
#include <Arduino.h>
#include "ESP8266WiFi.h"
//-- Pin definitions. Trace purpose only
#define tracePin0_loop 14
#define tracePin1_setup 12
char mySsid[]="xxx";
char myKey[]="yyy";
void setup() {
Serial.begin(115200);
//initialize trace -----------------------
pinMode(tracePin0_loop, OUTPUT);
pinMode(tracePin1_setup, OUTPUT);
digitalWrite(tracePin0_loop, 0);
digitalWrite(tracePin1_setup, 0);
delay (10000);
//end of trace initialization------------
digitalWrite(tracePin1_setup, 1);
WiFi.persistent(false); //avoid delays by flash operations
WiFi.mode(WIFI_OFF);
WiFi.setAutoConnect(false);
WiFi.setAutoReconnect(false);
digitalWrite(tracePin1_setup, 0);
delay (200);
digitalWrite(tracePin1_setup, 1);
WiFi.begin(mySsid, myKey);
digitalWrite(tracePin1_setup, 0);
}
// The loop function is called in an endless loop
void loop() {
digitalWrite(tracePin0_loop, !digitalRead(tracePin0_loop));
//do some stuff
delay(2); //cpu latency by WiFi (887ms) could occur here, or outside of this function
}
Debug Messages
SDK:2.2.1(cfd48f3)/Core:unspecified=0/lwIP:STABLE-2_1_2_RELEASE/glue:1.1-7-g82abda3/BearSSL:a143020
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
bcn 0
del if1
usl
mode : null
wifi evt: 8
mode : sta(18:fe:34:e8:1c:32)
add if0
wifi evt: 8
wifi evt: 2
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 9
cnt
connected with Vodafone-44013764, channel 11
dhcp client start...
wifi evt: 0
ip:192.168.5.56,mask:255.255.255.0,gw:192.168.5.1
wifi evt: 3
pm open,type:2 0
Additional information in the next post