Yep, this is the way that I ended up doing it in my ATTiny2313 clocks.
It works better than CTC timer, but it still had the same kinds of problems for me. (to a lesser severity)

-Adam

On 11/4/2013 4:57 PM, NeonJohn wrote:

On 11/04/2013 07:00 PM, Frank Bemelman wrote:

Assume you have an interrupt every 57 uS.


[untested code]

int timervalue = 0;
int msektimer = 0;
.
.
.

timer_int()
{ timervalue += 57; // add the uS that have passed since previous interrupt
  if(timervalue>1000) // a millisecond + some extra uS have past
  { timervalue -= 1000; // keep the remaining uS
    msektimer++; // keep track of total milliseconds
  }
}

Keeping track of seconds can be done in a similar way, just expand code.
Sure there is some jitter on the timervalues, but a jitter of 57uS
is usually not a problem for household purposes.
Clever.  I have been thinking about slowing the interrupts down
dramatically but I can't generate a precise decimal time interval that
way.  I'd been thinking about an algorithm but yours just solved it for
me.  Thanks much

John



--
You received this message because you are subscribed to the Google Groups 
"neonixie-l" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to neonixie-l+unsubscr...@googlegroups.com.
To post to this group, send an email to neonixie-l@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/neonixie-l/5278445B.1020704%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to