Reading the Arduino doc I see that millis() overflows every 9 hours
Reading this forum, I gather that millis() runs on Timer0
Reading the specs for the ATMega168 I see that Timer0 is 8 bit
Since Timer0 is only 8 bits I gather that the Arduino "system" must set the "prescalar" to update Timer0 at FAR LESS than the system clock frequency (otherwise we would never get to 9 hours).
I need something closer to "micros"()... well maybe not microseconds, but at least TENTHS of milliseconds.
Am I correct about the prescaler? Can I get in and adjust the prescaler to get finer timing out of millis() without breaking the Arduino?
dda
By the way....
If 8 bits gives 9 hours at milliseconds, I guess I would only get a bit over 30 seconds at microseconds!!!!!
As it happens, for my current needs, 30 seconds would be more than enough between Timer0 rollovers.
Thanks...
Your code snippet has helped me greatly in understanding what is going on.... especially after I compared it with what I found in:
D:\Arduino\hardware\cores\arduino\wiring.c (in my installation).
...
I will insert it in my project as is, then come back and tune it (if necessary) when all my code is in place.
mellis is changing millis in 0012 so it can go much longer without overflowing:
It should only overflow after 1200 hours instead of 9 with that fix. But timer0_overflow_count is going away and I haven't thought about how to adapt yet.