-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
Access WiFi Network and PWM #819
Comments
I thin you may have an EMC problem here. |
Hi, yes the resistor below the antenna are used to drive power to the LED that are then dimmed through the mosfet on the top. I don't know if is an EMC problem, because is very well replicable and doesn't appear if we turn ON the LED just after the connection has been completed. Out of this first time, then the module works fine. Does you know if there is any influence of the use of PWM and connection to the WiFi network? |
For reference the node restarts with ets Jan 8, 2013, rst cause: 4, boot mode:(1,6) |
rst cause: 4 means soft restart, for some reason the software watchdog is trigger. may this line blocks the WiFi too: |
This is the sketch, thanks #include <ESP8266WiFi.h>
#define RED_PIN 13
#define GREEN_PIN 12
#define BLUE_PIN 14
#define WHITE_PIN 2
#define POWER_ENABLE_LED 15
#define OFF 0
#define ON 1
uint32_t ui32Counter;
const char * cSSID ="SSID";
const char * cPW ="PW";
void setup()
{
pinMode(RED_PIN, OUTPUT); // Red
pinMode(GREEN_PIN, OUTPUT); // Green
pinMode(BLUE_PIN, OUTPUT); // Blue
pinMode(WHITE_PIN, OUTPUT); // White
pinMode(POWER_ENABLE_LED, OUTPUT); // Power Led Enable
analogWriteFreq(500);
analogWriteRange(255);
digitalWrite(RED_PIN, 0);
digitalWrite(GREEN_PIN, 0);
digitalWrite(BLUE_PIN, 0);
digitalWrite(WHITE_PIN, 0);
delay(500);
digitalWrite(POWER_ENABLE_LED, ON);
analogWrite(RED_PIN, 20);
ui32Counter=0;
Serial.begin(115200);
}
void loop()
{
delay(1000);
if (ui32Counter==1)
{
Serial.println("\n\rConnection to WiFi");
WiFi.begin(cSSID, cPW);
while (WiFi.status()!=WL_CONNECTED)
delay(1);
Serial.println("Connected");
Serial.println("\n\rWIFI_STA");
WiFi.mode(WIFI_STA);
delay(5000);
Serial.print("Local IP ");
Serial.println(WiFi.localIP());
}
ui32Counter++;
} |
After some test we have identified that the problem is with PWM only, if we turn ON the LEDs without PWM (full bright) there is no reset or any other type of issue. |
i get the error here to.
it is coming form timer1_isr_handler.
|
Really thanks for your support, unfortunately I'm not so in deep with this
SoC to understand.
I can understand that this timer is used for the SoftPWM, but I cannot
understand if there is a work around for this.
From Mobile.
|
I have seen this behaviour as well when I tried to use Servo library. I had to enable servo after wifi was connected. Will look into this... |
Thanks |
@Links2004 |
simply run: "$(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-objdump" -S $NAME.elf |
When the SDK calls SPIFlashWrite, flash memory is temporary unmapped from the CPU address space. If the timer interrupt fires at this moment, CPU can not read an instruction from flash, and fails with illegal instruction exception. One way to work around this would be to move interrupt handler into RAM. But then timer1_user_cb also has to be in RAM, as well as the rest of the functions it might call. Perhaps it would make sense to disable timer interrupts before calling SDK functions which save stuff into flash. |
Hi @igrr disabling the timer interrupts will result in PWM output at full HIGH or LOW based on when interrupts are disabled, it would not really solve the problem. Is SPIFlashWrite called only while joining the WiFi network? Thanks, |
SPIFlashWrite is called when WiFi config is changed. If you are joining the same network, you don't need to call WiFi.begin, SDK will join the last network without writing anything to flash. By the way, this is related to #836. As a summary, PWM needs the following things fixed:
|
Thanks for the tips, in the while I will workaround as are suggesting |
@igrr is there a way to read the last known network? So that at runtime we
can check if is the same of the sketch and skip the Wifi.begin().
In this way we could easily understand if we could use PWM from the very
begin or no.
Thanks.
From Mobile.
|
Hi,
I'm working on an ESP8266 based WiFi Bulb based on Souliss, is working fine out of the startup.
The ESP8266 cannot connect to a WiFi network (either as STA or AP) if the output pins are used in a PWM, this only at the connection time, after it works fine. We found this because the module need 3-4 seconds to connect with the WiFi network and so, turning the LEDs on only after the connection has made, will result into a delayed light.
So if we turn ON leds, then start the connection the ESP8266 turn off the outputs and reboot due to the watchdog. Is it related to the timer used for the software PWM?
The pin used are the following:
define PIN_RED 13
define PIN_GREEN 12
define PIN_BLUE 14
define PIN_WHITE 2
define PIN_ENABLE 15
A picture is following for reference
Thanks.
The text was updated successfully, but these errors were encountered: