Loading...
Pages: [1]   Go Down
Author Topic: Meddling with the runtime clock  (Read 192 times)
0 Members and 1 Guest are viewing this topic.
Space Coast Florida
Offline Offline
Jr. Member
**
Karma: 0
Posts: 58
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 334
Posts: 36433
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I need to certify that the rollover will be uneventful.
Use micros(), instead. Works the same way, but a much shorter fuse.
Logged

0
Offline Offline
God Member
*****
Karma: 37
Posts: 974
Get Bitlash: http://bitlash.net
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
extern volatile unsigned long timer0_millis;

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

-br
Logged

Global Moderator
Melbourne, Australia
Online Online
Shannon Member
*****
Karma: 226
Posts: 14100
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged


Space Coast Florida
Offline Offline
Jr. Member
**
Karma: 0
Posts: 58
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Just build your own time machine:
This might take longer than 49 days.
Logged

Global Moderator
Melbourne, Australia
Online Online
Shannon Member
*****
Karma: 226
Posts: 14100
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Good point.
Logged


Space Coast Florida
Offline Offline
Jr. Member
**
Karma: 0
Posts: 58
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 334
Posts: 36433
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 47
Posts: 2570
"We're a proud service of the Lost Electricity Reclamation Agency"
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
if ( millis() ... whatever ) { ...

use

Code:
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:
unsigned long ms = 4294957296;    //ten seconds before rollover
if ( ms ... whatever ) { ...
Logged

Get the infamous "One Million Ohms" board at tINDIE.com: http://tinyurl.com/BuyMohms

Pages: [1]   Go Up
Print
 
Jump to: