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
If you take two timestamp readings and your first reading is greater than the second, then your counter has wrapped. That is the basic way to detect a wrapping counter.
This, however, won't detect if a counter has wrapped multiple times, or the case where a counter has wrapped and happens to be greater than the first reading. Since you said this was an embedded system and your description makes your "counter" sound like a clock, see if you can set an interrupt to fire whenever the clock reaches zero (so that you will get an interrupt every time the clock resets). When this interrupt fires, increment a separate counter. This should effectively add extra precision to your clock and allow your counter to wrap without causing problems.