TimerOne Max Period

I have code snippet below:

#include <TimerOne.h>

void setup(void) {
  Timer1.initialize(5000000);
  Timer1.attachInterrupt(update);
}


void update() {

}

From Arduino Playground - HomePage, it says timer1 max period is 8388.608ms.

What I want is to call update method every 20 seconds, but it didn't work.

Timer1.initialize(5000000);

Every hour, update will take more than 10 seconds w/c is beyond timer1 max period

Any workaround? thanks

Every hour, update will take more than 10 seconds w/c is beyond timer1 max period

update() is an interrupt handler. No way in hell it can take 10 seconds.

Counter inside of ISR (update() function) should solve it. If counter overflows then set the global flag and do the rest of job in the loop().

I mean in update() method, it could take 10seconds let say it will turn few revolutions of a stepper motor.

jrgalia:
What I want is to call update method every 20 seconds, but it didn't work.

Definitely don't use Timer1 for this, its completely the wrong approach.

#define DELAY 20000ul

unsigned long last_time = 0ul ;

void loop ()
{
  if (millis () - last_time >= DELAY)
  {
    last_time += DELAY ;
    update () ;
  }
  ....
}

....