Go Down

Topic: Meddling with the runtime clock (Read 513 times) previous topic - next topic

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.

PaulS

Quote
I need to certify that the rollover will be uneventful.

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

billroy

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

Code: [Select]

extern volatile unsigned long timer0_millis;

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


-br

Nick Gammon


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
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

urthlight

Quote
Just build your own time machine:

This might take longer than 49 days.

Nick Gammon

Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

urthlight

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


Instead of the run-time clock?
Please explain.
Quote
but a much shorter fuse.

Fuse?

PaulS

Quote
Instead of the run-time clock?

No, instead of millis().

Quote
Fuse?

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

Jack Christensen

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

Code: [Select]
if ( millis() ... whatever ) { ...

use

Code: [Select]
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:

Code: [Select]
unsigned long ms = 4294957296;    //ten seconds before rollover
if ( ms ... whatever ) { ...

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy