If you look at a pic data sheet (one with timer 2), you can work out what to set the two register to in order to get a 1mS period. With a 4MHz clock, the timers are clocked at 1MHz and so you need to rollover every 1000 instructions. This can be done by setting the prescaler (T2CON) to 4, the period (PR2) to 250 and the postscaler to 1.
In C that would be,
To find out when it has rolled over you can check the TMR2IF bit in PIR1.
Have fun.
Mike.
In C that would be,
Code:
T2CON=0b00000101; //Pre=4, post=1 and timer2=on
PR2=249; //1 less than period
Code:
while(PIR1.TMR2IF==0); //wait for rollover
PIR1.TMR2IF=0; //reset flag
Count_mS++; //increment count
Have fun.
Mike.