Go Down

Topic: Reset Arduino millis() and micros() (Read 4870 times) previous topic - next topic

Gutza

Well, if you fiddle with millis() every second then it's reasonable to expect you won't be able to measure time very accurately... :) The intention is that one only calls this infrequently from the code, when they need to examine how the code behaves on overflows.

robtillaart

Quote
Well, if you fiddle with millis() every second then it's reasonable to expect you won't be able to measure time very accurately... The intention is that one only calls this infrequently from the code, when they need to examine how the code behaves on overflows.

Two remarks:

1) My example was just to show that when the millis() counter is reset at the right?/wrong? moment the SW Class get corrupted because it depends on the fact that the internal counter is not reset after a stopwatch is started.

2) If you allow a resettable millis() counter, it should be allowed to be reset as often as the programmer wants to. If if is only allowed infrequently (vague term) or under certain conditions makes it more complex to use as all the constrains should be guarded. Note that the SW class offers in fact such a resettable counter
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up