Timer1 period register

pic

I am using the PIC24F to make a simple stop watch and it was all going well.
I am using TIMER1 and various interupts.

The problem I am having is that I cannot seem to get TIMER1 to have a period of 1ms. at the moment I am putting 6250-1 into PR1 and it isn't accurate enough.

Does anyone know the formula or method I should use to work out what to put into PRI? I think the chip is currently running at 8MHz

Any help would be fantastic!

Best Answer

PR1 should be set to the the number of timer counts you want in a period, minus 1. To calculate that you need to know the instruction cycle rate. You say the chip "runs at" 8 MHz, so I guess that means the instruction cycle rate, not the clock rate. In that case there are 8000 instructions per ms, so PR1 should be set to 7999. Keep the prescaler at 1.