khoih-prog / TimerInterrupt

This library enables you to use Interrupt from Hardware Timers on an Arduino, such as Nano, UNO, Mega, etc. It now supports 16 ISR-based timers, while consuming only 1 hardware Timer. Timers' interval is very long (ulong millisecs). The most important feature is they're ISR-based timers. Therefore, their executions are not blocked by bad-behaving functions or tasks. This important feature is absolutely necessary for mission-critical tasks.
MIT License
98 stars 11 forks source link

ESP8266_ISR_Timer not working without ISR_Timer.run() on ESP8266 #14

Closed anand-010 closed 3 years ago

anand-010 commented 3 years ago

I want to add some timer interrupts to my existing project. I want to interrupt on every 10 seconds. I am selected ESP8266_ISR_Timer

#include <ESP8266_ISR_Timer.h>
ESP8266_ISR_Timer ISR_Timer;
. . . . 
void loop()
{
  ISR_Timer.run();
  if(some condition sets true) {
   timerId = ISR_Timer.setInterval(10000L, doingSomething10s);
   set condition to false;
 }
}

When i remove the ISR_Timer.run(); the timer not working. But it works with .run() on loop On the documentation I saw "// You don't need to and never call ISR_Timer.run() here in the loop(). It's already handled by ISR timer." While using .run() my project getting broken sometimes. How do i solve this problem.

khoih-prog commented 3 years ago

This is TimerInterrupt library. You are posting in this wrong library.

Anyway, you have to go back, use some examples to understand a little bit of how to use the ESP8266TimerInterrupt Library.

void loop()
{
  ...
  ISR_Timer.run();
  ...
}

The way you're using is completely wrong and I won't waste my time to explain.

TImerInterrupt, ISR require better knowledge to use them correctly.

I'm so sad that people misuse because of treating the library like some fast food which will create harm than benefit in the long run.