Hi,
I searched around a few threads trying to answer my question but I still can't see where my calculations are going wrong.
What I want to do is estimate roughly 5 minutes while processing in PIC and then do some other code.
I am using the PIC16F877A.
What I've done is setup up a TMR1 interupt. I set the TMR1H and TMR1L to be 0. Then everytime the interupt fires I increment a count variable which I keep track of in the core routine.
Now to calculate 5 minutes I did this:
1. 4/Osc Freq = Time per instruction = 4/8Mhz = 0.5:mu:Sec
2. Time it takes for the TMR1 interupt to fire is the time per instruction * the timer Low * the timer High registers = 0.5:mu:Sec * 256 * 256 = .5*256*256
= 0.032768 Sec
3. 1 sec would therefore be when the count = 1 / 0.032768 = ~30.5
4. So 5 minutes is the 30.5 * 300 = 9155
But when I check the timing on the chip this turns out to be 10 minutes. Can someone check my calculations?
Thanks,
Craig
I searched around a few threads trying to answer my question but I still can't see where my calculations are going wrong.
What I want to do is estimate roughly 5 minutes while processing in PIC and then do some other code.
I am using the PIC16F877A.
What I've done is setup up a TMR1 interupt. I set the TMR1H and TMR1L to be 0. Then everytime the interupt fires I increment a count variable which I keep track of in the core routine.
Now to calculate 5 minutes I did this:
1. 4/Osc Freq = Time per instruction = 4/8Mhz = 0.5:mu:Sec
2. Time it takes for the TMR1 interupt to fire is the time per instruction * the timer Low * the timer High registers = 0.5:mu:Sec * 256 * 256 = .5*256*256
= 0.032768 Sec
3. 1 sec would therefore be when the count = 1 / 0.032768 = ~30.5
4. So 5 minutes is the 30.5 * 300 = 9155
But when I check the timing on the chip this turns out to be 10 minutes. Can someone check my calculations?
Thanks,
Craig