Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By mugginsjm
#69226 Hi
I'm sure this has been discussed before but I can't find a solution.
I've built a light dimmer and the code uses hw-timer and includes the lines:
hw_timer_init(NMI_SOURCE, 0);
hw_timer_set_func(dimTimerISR);

ESPhttpUpdate.update() will only work if I comment out the second line.
I appreciate that this has something to do with disabling interrupts but having tried noInterrupts() I don't know how to proceed.
thanks
John
User avatar
By Jamie Clark
#71107 Hi,

I had the same problem. Found the solution elsewhere on this board.

Use the below function to disable the hardware timers.

void ICACHE_FLASH_ATTR hw_timer_disable(void)
{
ETS_FRC1_INTR_DISABLE();
TM1_EDGE_INT_DISABLE();
RTC_REG_WRITE(FRC1_CTRL_ADDRESS, 0);
}

And add the following code to your setup loop

ArduinoOTA.onStart([]() {
hw_timer_disable();
});

Here's the post where I found it:
viewtopic.php?p=34411