Quantcast
Channel: embedded timer wrap - Stack Overflow
Browsing all 4 articles
Browse latest View live

Answer by Jeff for embedded timer wrap

Sometimes I do it like this:ulong t1 = tick of last event;ulong t2 = current tick;if ( t1 > t2 ){ if ((ULONG_MAX-t1+t2+1)>=limit){ do something }} else {if ( t2 - t1 >= limit ){ do something}

View Article



Answer by Dmitry Poroh for embedded timer wrap

You don't have to cast it to signed. If "do something" is alarm handling code and limit is time interval.The best practice of the regular intervals is: ulong next_alarm_ticks = 0; void poll_alarm() {...

View Article

Answer by Daniel Fischer for embedded timer wrap

If it is guaranteed that t2 is conceptually always larger than t1, casting to a signed entity would be wrong. Arithmetic of unsigned integers is guaranteed by the standard to be correct modulo...

View Article

embedded timer wrap

Currently, im working on an embedded project, where most of the subsystems are based on timing.i have searched for many solutions to avoid issues with timers rolling over, but one thing still puzzles...

View Article
Browsing all 4 articles
Browse latest View live




Latest Images