Pages: 1 [2]   Go Down
Author Topic: Reset Arduino millis() and micros()  (Read 4407 times)
0 Members and 1 Guest are viewing this topic.
Romania
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 227
Posts: 14051
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Rob Tillaart

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

Pages: 1 [2]   Go Up
Jump to: