Meddling with the runtime clock

Is there some way to set the run-time clock other than waiting 49 days for the clock to turn over. I need to certify that the rollover will be uneventful.

I need to certify that the rollover will be uneventful.

Use micros(), instead. Works the same way, but a much shorter fuse.

I use code like this in the Bitlash rollover example (https://github.com/billroy/bitlash/blob/master/examples/rollover/rollover.ino):

extern volatile unsigned long timer0_millis;

void setMillis(unsigned long newtime) {
    uint8_t oldSREG = SREG;
    cli();
    timer0_millis = newtime;
    SREG = oldSREG;
})

-br

urthlight: Is there some way to set the run-time clock other than waiting 49 days for the clock to turn over. I need to certify that the rollover will be uneventful.

Just build your own time machine:

http://science.discovery.com/games-and-interactives/build-your-own-time-machine.htm

Just build your own time machine:

This might take longer than 49 days.

Good point.

Use micros(), instead.Works the same way,

Instead of the run-time clock? Please explain.

but a much shorter fuse.

Fuse?

Instead of the run-time clock?

No, instead of millis().

Fuse?

micros() ticks 1000 times faster than millis. Results in 0.01% of the time.

Substitute a variable in place of using millis() directly. Instead of

if ( millis() ... whatever ) { ...

use

unsigned long ms = millis();
if ( ms ... whatever ) { ...

Make sure the code works as desired that way, then to test what happens around rollover, something like this:

unsigned long ms = 4294957296;    //ten seconds before rollover
if ( ms ... whatever ) { ...