Being reseted at startup, and being defined 32bit, I see that MS_TIMER will overflow once each ~50 days.
There is “anything” signalling the situation of MS_TIMER overflow? Or should I check for the previous value of MS_TIMER every function tick to detect it?
7.3.2 Example: Delay Loop
An important detail about MS_TIMER is that it overflows (�rolls over�) approximately every 49 days, 17
hours. This behavior causes the following delay loop code to fail:
/* THIS CODE WILL FAIL!! */
endtime = MS_TIMER + delay;
while (MS_TIMER < endtime) {
//do something
}
If �MS_TIMER + delay� overflows, this returns immediately. The correct way to code the delay loop so
that an overflow of MS_TIMER does not break it, is this:
endtime = MS_TIMER + delay;
while ((long)MS_TIMER - endtime < 0) {
//do something
}