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 ArticleAnswer 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 ArticleAnswer 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 Articleembedded 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
More Pages to Explore .....