Hi,

Just before entering the loop start your timer. Make sure you clear it and setup the prescale right before starting it. Take a counter variable and clear it too.

Now inside your loop poll for the timer overflow bit (mention PIC I will clarify or read DATASHEET). If it is one clear it and increment your counter variable. Depending on your oscillator and prescaler you know how long it takes for the timer to count till overflow. When your counter inside the loop exceeds a preset jump to anywhere you like.

Only caution is your loop should not take more time to execute than one timer cycle

I use this in my menu routines for autoexit when a user forgets to get out of the menu.

Hope this helps