I need to deal with a counter that gives me ticks for my application. The counter is 32bits so what i need to know is how to deal with it when it wraps. for example:
I h
I think one of the easiest ways to do this, would be to have another counter (lets call it Wrap counter, let this be a static global for the timer module), count up each time your original 32 bits counter wrapped.
In the function where your counter is ticking away, everytime this counter reaches its maximum count, you have your Wrap counter increment. So when you are reading the function which returns whether or not the timer has elapsed, you also read the Wrap counter, to check how many times it wrapped over. The important thing is, to also do this: everytime you read the wrap counter, you want to clear it, for your next reading.