I wonder if calling such a line:
analogWrite(4, 1024);
could cause ESP8266 to hang?
I'm asking because my ESP8266 hangs after about a week of normal working. This is terrible to debug but I managed to narrow down the problem to a function which uses analogWrite(). I analyzed it and it occurred to me that the values are ranging from 0 to 1024 instead of from 0 to 255, right?
This is analogWrite()
function from Arduino:
extern "C" void analogWrite(uint8_t pin, int value) {
if (pin >= ESP_PINS_OFFSET) {
__analogWrite(pin - ESP_PINS_OFFSET, value);
}
else {
wifio::analogWrite(pin, value);
}
}
It calls some SDK's commands which I don't have knowledge about and I'm not sure if it's possible to verify what they're doing?
Calling analogWrite()
with a value outside the allowed range will likely cause undefined behavior; you should definitely correct this before attending to anything else:
Syntax for the ESP8266: analogWrite(pin, valueParameters pin: the pin to write to. value: the duty cycle: between 0 (always off) and 1023 (always on).
Forget other debugging tasks until you get this corrected.