depending what else your PIC will do, you can use COUNT or internal timers to count everything in background.